Skip to content

Instantly share code, notes, and snippets.

@nickserv
Created November 18, 2013 20:26
Show Gist options
  • Save nickserv/7534704 to your computer and use it in GitHub Desktop.
Save nickserv/7534704 to your computer and use it in GitHub Desktop.
Haskell practice
divisible x y = x `mod` y == 0
main = print $ sum [x | x <- [1..999], x `divisible` 3 || x `divisible` 5]
factorial 1 = 1
factorial n = n * factorial (n-1)
main = print $ factorial 5
-- |Reverses a list (top level elements only).
reverse2 :: [a] -> [a]
reverse2 [] = []
reverse2 list = reverse2 (tail list) ++ [head list]
main = print $ reverse2 ["g", "f", "e", "d", "c", "b", "a"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment