Skip to content

Instantly share code, notes, and snippets.

@prakashk
Last active August 29, 2015 14:01
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 prakashk/e464478b2697c5ef2eaa to your computer and use it in GitHub Desktop.
Save prakashk/e464478b2697c5ef2eaa to your computer and use it in GitHub Desktop.
Implementation of few haskell builtins
-- https://questhub.io/realm/haskell/quest/537bb4e2bbd0bed61d00007d
head :: [a] -> a
head [] = error "head: empty list"
head (x:xs) = x
tail :: [a] -> [a]
tail [] = error "tail: empty list"
tail (x:xs) = xs
zip :: [a] -> [b] -> [(a,b)]
zip [] _ = []
zip _ [] = []
zip (x:xs) (y:ys) = (x,y) : zip xs ys
map :: (a -> b) -> [a] -> [b]
map _ [] = []
map f (x:xs) = f x : map f xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment