5. előadás
Tail recursion
fact' :: Integer -> Integer
fact' n = factH n 1
where factH :: Integer -> Integer -> Integer
factH 0 c = c
factH n c = factH (n-1) (n*c)
length' :: [a] -> Int
length' arr = lengthH arr 0
lengthH :: [a] -> Int -> int
lengthH [] c = c
lengthH (_:xs) c = lengthH xs (c+1)
Currying
Ez ugyan az, mint