99 Elm Problems/Problem 9
Appearance
Pack consecutive duplicates of list elements into sublists. If a list contains repeated elements they should be placed in separate sublists. Elements that are not repeated should be placed in a one element sublist.
import Html exposing (text)
import List
pack : List a -> List (List a)
-- your implementation goes here
main = pack [1,1,1,2,3,3,3,4,4,4,4,5,6,6] |> toString |> text
Result:
[[1,1,1], [2], [3, 3, 3], [4, 4, 4, 4], [5], [6, 6]]