99 Elm Problems/Problem 10/Solutions
Appearance
Solution 1: Recursive version
runLengthEncode list =
case list of
[] -> []
[ x ] -> [ (x, 1) ]
x :: xs ->
case runLengthEncode xs of
[] -> []
(x', n) :: xs' ->
if x == x' then
(x, n + 1) :: xs'
else
( x, 1 ) :: (x', n) :: xs'