5 ms·
Haskell version that is fully lazy, (though not point-free or completely idiomatic). import Data.List (group) rle = map
by jamwt 16y ago
Haskell version that is fully lazy, (though not point-free or completely idiomatic).
import Data.List (group)
rle = map (\x-> (length x, head x)) . group
main = print $ rle "aaaabccaadeeee"
- brehaut 16y agoYou can replace (\x -> (length x, head x)) with (length &&& head) if you import Control.Arrow to make it fully point free