12 lines
260 B
Haskell
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
|
|
|