Define a function called at-least-two?
that takes one Nat argument and evaluates to an Atom.
at-least-two?
evaluates to 't
if the Nat is greater than or equal to 2 otherwise it evaluates to 'nil
.
Note: The only Nat eliminator you should need in the body of at-least-two?
is which-Nat
.
Rewrite the definition of +
(in frame 3.27) using the rec-Nat
eliminator instead of the iter-Nat
eliminator.
(define step-+
(lambda (sum-n-1)
(add1 sum-n-1)))
(define +
(lambda (n j)
(iter-Nat n
j
step-+)))
Define a function called exp
that takes two Nat arguments and evaluates to a Nat. exp
evaluates to the exponentiation, a^b
, of the two passed arguments.
Define a function called max
that takes two Nat arguments and evaluates to a Nat. max
evaluates to the larger of the two passed arguments.