24 lines
729 B
Haskell
24 lines
729 B
Haskell
doubleMe x = x + x
|
|
|
|
doubleUs x y = doubleMe x + doubleMe y
|
|
|
|
doubleSmallNumber x = if x > 100
|
|
then x
|
|
else x*2
|
|
|
|
doubleSmallNumber' x = (if x > 100 then x else x*2) + 1
|
|
|
|
-- boom bangs, ya heard???
|
|
boomBangs xs = [ if x< 10 then "BOOM!" else "BANG!" | x <- xs, odd x]
|
|
-- remember, [function | set, predicate] 'fucking stupid predicate'
|
|
|
|
schtankyList x = [ x*y | x <- [2,5,10], y <- [8,10,11]]
|
|
|
|
-- Now Writing our own custom list function
|
|
length' xs = sum [1 | _ <- xs]
|
|
-- use dummy variable _, draw an element from a list and replace it with 1. Sum all of those.
|
|
|
|
--- Strings are lists! We can use list comprehensions on them.
|
|
removeNonUppercase st = [ c | c <- st, c `elem` ['A'..'Z']]
|
|
|