Created
February 9, 2015 13:47
-
-
Save zudochkin/5459f617c4ae2de51403 to your computer and use it in GitHub Desktop.
Haskell: first steps
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
main :: IO() | |
len :: [a] -> Int | |
len [] = 0 | |
len (_:xs) = 1 + len xs | |
main = putStrLn $ "The length is: " ++ show (len [1, 2, 3, 4, 5]) |
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
main :: IO() | |
reverse' :: [a] -> [a] | |
reverse' [x] = [x] | |
reverse' (x:xs) = reverse' xs ++ [x] | |
main = putStrLn $ "The reverse is: " ++ show (reverse' [1, 2, 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment