| Copyright | © Frank Jung 2020 |
|---|---|
| License | GPL-3 |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
ZipFold
Description
From Zipping with Folds which is based on How to Zip with Folds.
The Preludes version of zip uses recursion:
zip :: [a] -> [b] -> [(a,b)] zip [] _bs = [] zip _as [] = [] zip (a:as) (b:bs) = (a,b) : zip as bs
But, this won't work for streams. The version included below does work with
streams. It uses a recursive type to represent the stream data. This
matches from the beginning of the stream. You could match from the end of
the stream by swapping foldr with foldl.
Documentation
Defines a recursive type.