Skip to content

Instantly share code, notes, and snippets.

@zudochkin
Created February 9, 2015 13:47
Show Gist options
  • Save zudochkin/5459f617c4ae2de51403 to your computer and use it in GitHub Desktop.
Save zudochkin/5459f617c4ae2de51403 to your computer and use it in GitHub Desktop.
Haskell: first steps
main :: IO()
len :: [a] -> Int
len [] = 0
len (_:xs) = 1 + len xs
main = putStrLn $ "The length is: " ++ show (len [1, 2, 3, 4, 5])
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