Idris2/tests/ideMode/ideMode005/Tuples.idr
2021-05-14 13:47:35 +01:00

16 lines
459 B
Idris

init : a -> c -> List b -> List (a, b, c)
init a c = map (uncurry (,)) . map (a,) . map (,c)
unzip : List (a, b) -> (List a, List b)
unzip [] = ([], [])
unzip ((a, b) :: abs)
= let (as, bs) = unzip abs in
(a :: as, b :: bs)
unzip4 : List (a, b, c, d) -> (List a, List b, List c, List d)
unzip4 [] = ([], [], [], [])
unzip4 (abcd :: abcds)
= let (a, b, c, d) = abcd
(as, bs, cs, ds) = unzip4 abcds
in (a :: as, b :: bs, c :: cs, d :: ds)