Problem 14 Solutions
Solution 1 - recurse
duplicate : List a -> List a
duplicate list =
case list of
[] ->
[]
x :: xs ->
x :: x :: duplicate xs
Solution 2 - concatMap
duplicate : List a -> List a
duplicate list =
List.concatMap (\x -> [x, x]) list
Solution 3 - fold
duplicate : List a -> List a
duplicate list =
List.foldl (\x y -> y ++ [x, x]) [] list