We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is pretty inefficient haskell, as you have to traverse the entire list and make a copy of it each time you use the ++ operator. A more efficient solution is rev = foldl (\acc x -> x : acc) []. this way, you avoid the expense of using the ++ operator
Reverse a List
You are viewing a single comment's thread. Return to all comments →
This is pretty inefficient haskell, as you have to traverse the entire list and make a copy of it each time you use the ++ operator. A more efficient solution is
rev = foldl (\acc x -> x : acc) []
. this way, you avoid the expense of using the ++ operator