411 REFERENCE · Wikibooks
99 Elm Problems/Problem 9/Solutions
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Solution 1: Recursive version
pack list =
case list of
[] -> []
[ x ] -> [ [ x ] ]
x :: xs ->
case pack xs of
[] -> []
x' :: xs' ->
if List.member x x' then
(x :: x') :: xs'
else
[ x ] :: x' :: xs'