Section 22
Want more of a challenge? View in
iconic
form (
experimental
)
# MATH show an example of recursive evaluation
# skipping over a lot of definitions and desugarings
[
hear
]
(define easy-factorial /
? f /
? x /
if
(>
(x)
0)
(*
(x)
/ f
(f)
(-
(x)
1)
)
1);
[
hear
]
(define factorial /
? x /
if
(>
(x)
0)
(*
(x)
/
factorial /
-
(x)
1)
1);
[
hear
]
(=
(easy-factorial
(easy-factorial)
0)
1);
[
hear
]
(=
(easy-factorial
(easy-factorial)
1)
1);
[
hear
]
(=
(easy-factorial
(easy-factorial)
2)
2);
[
hear
]
(=
(easy-factorial
(easy-factorial)
3)
6);
[
hear
]
(=
(easy-factorial
(easy-factorial)
4)
24);
[
hear
]
(=
(easy-factorial
(easy-factorial)
5)
120);
[
hear
]
(=
(factorial 0)
1);
[
hear
]
(=
(factorial 1)
1);
[
hear
]
(=
(factorial 2)
2);
[
hear
]
(=
(factorial 3)
6);
[
hear
]
(=
(factorial 4)
24);
[
hear
]
(=
(factorial 5)
120);