Post #2735425
2026-05-10 20:53 UTC
@jer_gib@functional.cafe More concretely, what's the nicest way you know of to define `transpose`? The actual implementation in the Haskell standard library is gross. The best I've come up with is
transpose = foldr (zipWithExt (++) . map pure) []
where `zipWithExt :: (a -> a -> a) -> [a] -> [a] -> [a]` is the analogue of `zipWith` which extends to the longer of its two list arguments instead of truncating to the shorter.
Replies (1)
-
@jer_gib@functional.cafe 2026-05-11 08:11
@byorgey@mathstodon.xyz I call that operator "long zip with", or `lzw` for short. It's in my Underappreciated Unfold paper (1998), but also in my dissertation (1991).