gyb template for ZipSequence


(Alexander Momchilov) #1

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?

- Regards,
        Alexander Momchilov


(Dave Abrahams) #2

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!

···

on Wed Nov 09 2016, Alexander Momchilov <swift-evolution@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?

--
-Dave


(Ben Cohen) #3

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@swift.org> wrote:

on Wed Nov 09 2016, Alexander Momchilov <swift-evolution@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution