Skip to content

Instantly share code, notes, and snippets.

@blackbird014
Created July 9, 2013 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackbird014/5960696 to your computer and use it in GitHub Desktop.
Save blackbird014/5960696 to your computer and use it in GitHub Desktop.
Haskell function to reverse a list. in line 3 we see that a list goes in a list in 4-7 is defined the function. line 6 empty in empty line 7 reads like follows: applied to a list made up by an element followed by all the remainning it gives the same funtion applied to all the remaining plus the element itself.
module MyReverse where
myReverse :: [a] -> [a]
myReverse l = rev l []
where
rev [] a = a
rev (x:xs) a = rev xs (x:a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment