[swift-evolution] Proposal: Implement == and < for tuples where possible, up to some high arity

Brent Royal-Gordon brent at architechies.com
Mon Dec 7 18:17:34 CST 2015


>>>      return zip([a1,b1,c1,d1,e1], [a2,b2,c2,d2,e2]).lazy.filter(==).first.flatMap(<) ?? false
>>> 
>>> Okay, so that wasn’t quite as easy as I thought when I started writing
>>> the email.
>> 
>> That also allocates two intermediate arrays (the inputs to zip()).
> 
> And relies on all variables having the same type.

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.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list