99 Elm Problems/Problem 7/Solutions

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Solution 1: Recursive version

flatten list =
    case list of
        Elem e -> [ e ]
        NestedList [] -> []
        NestedList (head :: tail) -> flatten head ++ flatten (NestedList tail)