wtfunctional/examples/01_haskell_recursion.hs
Oliver Rümpelein 7657c1a493 First draft of talk:
* Dafunc? concetpually almost ready
 * Started haskell introduction
2016-04-20 12:26:05 +02:00

12 lines
260 B
Haskell

extract :: [a] -> a
extract [] = error("Too few objects")
extract (x:xs) = x
a = extract [1,2,3,4,5]
addto :: (Num a) => [a] -> a -> [a]
addto [] _ = [] -- edge case (list empty)
addto (x:xs) y = (x+y) : addto xs y
b = [1..4]
-- c == [5,6,7,8]
c = addto b 4