I've been doing a lot of work with tuples and lists of tuples recently and I've been wondering if I'm being sensible.
Things feel awkward and clunky which for me signals that I'm doing something wrong.
For example I've written three convenience functions for getting the first, second and third value in a tuple of 3 values.
Is there a better way I'm missing?
Are there more general functions that allow you to compose and manipulate tuple data?
Here are some things I am trying to do that feel should be generalisable.
Extracting values: Do I need to create a version of fst,snd,etc... for tuples of size two, three, four and five, etc...?
fst3(x,_,_) = x
fst4(x,_,_,_) = x
Manipulating values: Can you increment the last value of every tuple in a list of pairs and then use that same function to increment the last value of every tuple in a list of triples?
Zipping and Unzipping values: There is a zip and a zip3. Do I also need a zip4? or is there some way of creating a general zip function?
Sorry if this seems subjective, I honestly don't know if this is even possible or if I'm wasting my time writing 3 extra functions every time I need a general solution.
Thank you for any help you can give!