11 lines
442 B
Text
11 lines
442 B
Text
main :: [sys_message]
|
|
main = [Stdout (lay (map test tests))]
|
|
where test (n,x,y) = "F" ++ show n ++ "(" ++ show x ++ ","
|
|
++ show y ++ ") = " ++ show (f n x y)
|
|
tests = [(0,0,0), (1,1,1), (1,3,3),
|
|
(2,1,1), (2,2,1), (3,1,1)]
|
|
|
|
f :: num->num->num->num
|
|
f 0 x y = x+y
|
|
f (n+1) x 0 = x, if n >= 0
|
|
f (n+1) x (y+1) = f n k (k + y + 1), if n >= 0 where k = f (n+1) x y
|