[swift-evolution] gyb template for ZipSequence

Ben Cohen ben_cohen at apple.com
Thu Nov 10 21:34:02 CST 2016


It might be worth noting that, in the meantime, you can nest zips as a workaround without having to define zip for n-tuples:

let integers = [1, 2, 3, 4, 5]
let strings = ["a", "b", "c", "d", "e"]
let doubles = [1.0, 2.0, 3.0, 4.0, 5.0]

for (integer, (string, double)) in zip(integers, zip(strings, doubles)) {
    print("\(integer) \(string) \(double)")
}

> On Nov 9, 2016, at 9:29 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> on Wed Nov 09 2016, Alexander Momchilov <swift-evolution at swift.org> wrote:
> 
>> This stack overflow question
>> <http://stackoverflow.com/q/40517760/3141234> asks about using zip
>> with more than 3 sequences. I referred the OP to the generics
>> manifesto
>> <https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#variadic-generics>,
>> which describes the (current) lack of varadiac generics, which
>> prohibits the ability to express (in pure Swift) the ability to write
>> ZipSequence for an arbitrary number of sequences.
>> 
>> I wrote up a (rough) gyb template for creating
>> ZipSequences. <https://github.com/amomchilov/ZipNsequence/blob/master/ZipNSequence.swift.gyb>
>> Is there any interest in adding something like this to the stdlib?
> 
> Yes, it's always been part of the (eventual) plan, so it's cool to see.
> It's out of scope for phase 1 of the Swift 4 planning work, but when
> phase 2 comes along you should submit a proposal!
> 
> -- 
> -Dave
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161110/5b568403/attachment.html>


More information about the swift-evolution mailing list