Created
July 9, 2013 19:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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