99 道 Elm 难题/难题 9/解答
外观
< 99 道 Elm 难题 | 难题 9
解答 1:递归版本
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'