Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
12 lines (9 sloc) 266 Bytes
-- P09 Pack consecutive duplicates of list elements into sublists.
import Data.List
-- Built-in function
f0 :: Eq a => [a] -> [[a]]
f0 = group
-- Recursion with "span"
f1 :: Eq a => [a] -> [[a]]
f1 [] = []
f1 (x:xs) = let (a, b) = span (== x) xs in (x : a) : f1 b