<div dir="ltr">I'd love to see a type like tuple<(A,B,C),D>, that is equivalent to (A,B,C,D).<div>Also you could have functions on the tuple:</div><div><br></div><div>for (A,B,C,D,E,F):</div><div><br></div><div>func prefix<A,B,C,...>() -> (A,B,C)</div><div>func suffix<...,D,E,F>() -> (D,E,F)<br></div><div><br></div><div>Then you may be able to do something like this:</div><div>func ==<A:tuple<>, B: tuple<>, where A: Equatable, B:Equatable>(lhs: tuple<A,B>, rhs: tuple<A,B>) {</div><div> return ls.prefix() as A == rhs.prefix() as A && lhs.suffix() as B == rhs.suffix() as B</div><div>}</div><div>extension tuple<Equatable,Equatable>: Equatable {}</div><div><br></div><div>The downside I can see for that is that it will match the same tuple n different ways. You can overcome this by only allowing tuple<A,B> to append a single element, but it's less useful. Alternatively it will always match the function with the most elements in the left-most argument, and cannot match against the empty tuple.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 8, 2015 at 11:18 AM, Dmitri Gribenko via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Dec 7, 2015 at 4:17 PM, Brent Royal-Gordon<br>
<<a href="mailto:brent@architechies.com">brent@architechies.com</a>> wrote:<br>
>>>> return zip([a1,b1,c1,d1,e1], [a2,b2,c2,d2,e2]).lazy.filter(==).first.flatMap(<) ?? false<br>
>>>><br>
>>>> Okay, so that wasn’t quite as easy as I thought when I started writing<br>
>>>> the email.<br>
>>><br>
>>> That also allocates two intermediate arrays (the inputs to zip()).<br>
>><br>
>> And relies on all variables having the same type.<br>
><br>
> Both true. What actually happened was, when I looked at the tuple version, I thought “okay, that’s basically just zipping the two together and then running < on each pair". In trying to write the email making that point, I discovered that this “easy” alternative is actually ridiculously complicated once you translate it from a vague notion to running code, and thought that was funny.<br>
<br>
</span>We have lexicographicalCompare(), so it is not that complicated after all.<br>
<span class="im HOEnZb"><br>
Dmitri<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
</span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>