<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">It's pretty easy to build your own Zips. Not sure the language really needs this. For example, I recently built a zip that produces (T?, T?) which fills one of the two with nil until both lists are consumed:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> longZip&lt;S0: SequenceType, S1: SequenceType&gt;(seq0: S0, <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> seq1: S1) -&gt;</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span>AnyGenerator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&lt;(</span>S0<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">?, </span>S1<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">?)&gt; {</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> generators = (seq0.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">generate</span>(), seq1.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">generate</span>())</div><div style="margin: 0px; line-height: normal; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>anyGenerator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> items = (generators.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">next</span>(), generators.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">next</span>())</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> (.None, .None) = items {<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span>}</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> items</div><div style="margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; line-height: normal;" class="">}</div><div class=""><br class=""></div></div></div><div class="">I'm rather fond of this variant although I don't know if it's generally useful enough to be worth even considering for the language</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 4:01 PM, Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">zip2 (aka "zip") is present in Swift. zip3 is often useful, but not built-in.</div><div class=""><br class=""></div><div class="">It can be achieved by using multiple copies of zip2:</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">&nbsp; for (one, (two, three)) in zip(list1, zip(list2, list3)) ...</font></div><div class=""><br class=""></div><div class="">It seems like either of these could make sense:</div><div class=""><br class=""></div><div class="">- Put some reasonable number of implementations, like zip2...zip10, in the standard library, using gyb.</div><div class=""><br class=""></div><div class="">- Have the compiler generate them on the fly as requested by the user.</div><div class=""><br class=""></div><div class="">Or, some alternate approaches:</div><div class=""><br class=""></div><div class="">- Don't do this right now, but count it as motivation for a macro system.</div><div class=""><br class=""></div><div class="">- Consider making Swift's pattern-matching system extensible, which might allow custom array-based patterns, like "<font face="monospace, monospace" class="">for [one, two, three] in zip(list1, list2, list3)</font>". &nbsp;(I've been thinking of writing a proposal for this anyway.)</div><div class=""><br class=""></div><div class=""><br class=""></div>Does anyone else care about zip3-and-higher? How do these options sound?<div class=""><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class="">Jacob Bandes-Storch<br class=""></div></div></div></div>
</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=r5jpKsi6nat7oa43lpCLi5GRGm2utDkbDscuFklXZ2dpJV0zNI2taKharutwt-2Bus7n3I76kisqv6njHT3Hyefe6Nue-2Bth-2B8wDDaJyrCUgOMcBdG2hx-2FHrz56IfCJi-2BWresIoWaecBFLzVvf85lMXp4y4-2FDFnzJDlRyP683EsFxeFoov7X4eMCST1JjA1JE9W5HwArq8GseXF5MKEGbNBCUcX5nvU9rPCaJ-2FSIV6xSbE-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>