AlexanderM
(Alexander Momchilov)
November 10, 2016, 3:24am
1
This stack overflow question <swift - Is there a zip function to create tuples with more than 2 elements? - Stack Overflow ; asks about using zip with more than 3 sequences. I referred the OP to the generics manifesto <swift/GenericsManifesto.md at main · apple/swift · GitHub , 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
dabrahams
(Dave Abrahams)
November 10, 2016, 5:29am
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
<swift - Is there a zip function to create tuples with more than 2 elements? - Stack Overflow ; asks about using zip
with more than 3 sequences. I referred the OP to the generics
manifesto
<swift/GenericsManifesto.md at main · apple/swift · GitHub ,
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
(Ben Cohen)
November 11, 2016, 3:34am
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
<swift - Is there a zip function to create tuples with more than 2 elements? - Stack Overflow ; asks about using zip
with more than 3 sequences. I referred the OP to the generics
manifesto
<swift/GenericsManifesto.md at main · apple/swift · GitHub ,
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