Skip to content

Instantly share code, notes, and snippets.

@paulosuzart
Created August 13, 2010 18:56
Show Gist options
  • Save paulosuzart/523362 to your computer and use it in GitHub Desktop.
Save paulosuzart/523362 to your computer and use it in GitHub Desktop.
{- learning from http://learnyouahaskell.com/ -}
doubleMe x = x + x
doubleSmall x = if x > 100
then x
else x * 2
len xs = sum [1 | _ <- xs]
per = ("Paulo", 28)
removeNonUppercase :: [Char] -> [Char]
removeNonUppercase st = [c | c <- st, elem c ['A'..'Z']]
pm 7 = "I'm a Seven"
pm _ = "You have not typed a Seven :("
replicate' :: (Num i, Ord i) => i -> a -> [a]
replicate' n x
| n <= 0 = []
| otherwise = x:replicate' (n-1) x
take' :: (Num i, Ord i) => i -> a -> [a]
take' n _
| n <= 0 = []
take' _ [] = []
take' n (c:xs) = c : take' (n-1) xs
reverse' :: (Ord i) => [i] -> [i]
reverse' [] = []
reverse' (x:xs) = reverse' xs ++ [x]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment