3 ms·
It’s just the definition of a tuple. Having fixed length and tuples of different lengths being different types is important because it means you can pattern mat
by jolux 8y ago
It’s just the definition of a tuple. Having fixed length and tuples of different lengths being different types is important because it means you can pattern match on them and from that you also get things like destructuring and so on and so forth that you do not have with lists. You can call it a limitation but it’s more just about the design philosophy of a tuple. You can get the nth element by pattern matching, which you cannot do with growable data structures. You probably do not want a function that operates on all tuples in the first place, because making that possible massively reduces their utility for places where they are useful in the first place. Basically, use a different/real collection type if you need to do this. Tuples offer specific features that other types do not have and are constrained in their utility because of this. Records and arrays are often a better choice.