zip package:containers

zip takes two sequences and returns a sequence of corresponding pairs. If one input is short, excess elements are discarded from the right end of the longer sequence.
When a key is found in both maps, apply a function to the key and values to produce an action and use its result in the merged map.
When a key is found in both maps, apply a function to the key and values and use the result in the merged map.
zipWithMatched
:: (Key -> x -> y -> z)
-> SimpleWhenMatched x y z
When a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map. This is the fundamental WhenMatched tactic.
When a key is found in both maps, apply a function to the key and values and maybe use the result in the merged map.
zipWithMaybeMatched
:: (Key -> x -> y -> Maybe z)
-> SimpleWhenMatched x y z
When a key is found in both maps, apply a function to the key and values and use the result in the merged map.
zipWithMatched :: (k -> x -> y -> z)
-> SimpleWhenMatched k x y z
When a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map. This is the fundamental WhenMatched tactic.
When a key is found in both maps, apply a function to the key and values and maybe use the result in the merged map.
zipWithMaybeMatched :: (k -> x -> y -> Maybe z)
-> SimpleWhenMatched k x y z
When a key is found in both maps, apply a function to the key and values to produce an action and use its result in the merged map.
When a key is found in both maps, apply a function to the key and values and use the result in the merged map.
zipWithMatched :: (k -> x -> y -> z)
-> SimpleWhenMatched k x y z
When a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map. This is the fundamental WhenMatched tactic.
When a key is found in both maps, apply a function to the key and values and maybe use the result in the merged map.
zipWithMaybeMatched :: (k -> x -> y -> Maybe z)
-> SimpleWhenMatched k x y z
When a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map. This is the fundamental WhenMatched tactic.
zip3 takes three sequences and returns a sequence of triples, analogous to zip.
zip4 takes four sequences and returns a sequence of quadruples, analogous to zip.
zipWith generalizes zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two sequences to take the sequence of corresponding sums.
zipWith3 takes a function which combines three elements, as well as three sequences and returns a sequence of their point-wise combinations, analogous to zipWith.
zipWith4 takes a function which combines four elements, as well as four sequences and returns a sequence of their point-wise combinations, analogous to zipWith.
Unzip a sequence of pairs.
unzip ps = ps `seq` (fmap fst ps) (fmap snd ps)
Example:
unzip $ fromList [(1,"a"), (2,"b"), (3,"c")] =
(fromList [1,2,3], fromList ["a", "b", "c"])
See the note about efficiency at unzipWith.
Unzip a sequence using a function to divide elements.
unzipWith f xs == unzip (fmap f xs)
Efficiency note: unzipWith produces its two results in lockstep. If you calculate unzipWith f xs and fully force either of the results, then the entire structure of the other one will be built as well. This behavior allows the garbage collector to collect each calculated pair component as soon as it dies, without having to wait for its mate to die. If you do not need this behavior, you may be better off simply calculating the sequence of pairs and using fmap to extract each component sequence.