Problem 5 Solutions

Solution 1 - fold

myReverse : List a -> List a
myReverse xs =
    List.foldl (::) [] xs

Solution 2 - recursion

myReverse : List a -> List a
myReverse list =
    case list of 
        [] ->
            []

        x :: xs ->
            (myReverse xs) ++ [x]

Back to Problem 5

results matching ""

    No results matching ""