(define factorial
(lambda (n)
(define factorial-product
(lambda (a b)
(if (= b 0)
a
(factorial-product (* a b) (- b 1)))))
(factorial-product 1 n)))
> (factorial 5)
120
> (factorial-product 1 5)
Error: factorial-product: undefined;
factorial is defined at the top level of the Scheme environment
and so it is visible to the Scheme interpreter.
factorial-product is defined in the body of factorial, and it is not visible outside the body.