You are viewing a single comment's thread. Return to all comments →
Haskell:
rev l = [ l !! (i-1) | i <- [length l, length l - 1 .. 1]]
[length l, length l - 1 .. 1] -- generates a list of decreasing indexes
l !! (i-1) -- accesses the (i-1)th element of l
all within a list comprehension.
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a List
You are viewing a single comment's thread. Return to all comments →
Haskell:
[length l, length l - 1 .. 1] -- generates a list of decreasing indexes
l !! (i-1) -- accesses the (i-1)th element of l
all within a list comprehension.