I am attempting to write a function called that takes a list of triples and produces a 3-tuple of three lists. For instance, the function called on [(a,b,c), (d, e, f), (g, h, i)] should produce ([a,d,g], [b, e, j], [c, f, i]).
I have this so far:
-- This gives the head of a 3-tuple
fst3 :: (a, b, c) -> a
fst3 (x, _, _) = x
unzipTriples :: [(a, b, c)] -> a
unzipTriples (x : y : z : xs) = (fst3 x : fst3 y : fst3 z, unzipTriples xs)
I thought this would create a list [a, d, g] and then add it to the 3-tuple and do the rest for the remaining list. How can I improve this wrong function?