I am looking for functions like zip / unzip in functional programming languages (e.g. Haskell, Scala).
Haskell reference examples . Country:
Input: zip [1,2,3] [9,8,7]
Output: [(1,9),(2,8),(3,7)]
Unpack:
Input: unzip [(1,2),(2,3),(3,4)]
Output: ([1,2,3],[2,3,4])
In R, the input will look something like this. For clamping:
l1 <- list(1,2,3)
l2 <- list(9,8,7)
l <- Map(c, l1, l2)
To unpack:
tuple1 <- list(1,2)
tuple2 <- list(2,3)
tuple3 <- list(3,4)
l <- Map(c, tuple1, tuple2, tuple3)
Is there a built-in solution / library in R that implements these methods? (FP functions have quite a few names - searching for zip / unzip and R only gave me results for compressing / decompressing files.)