TEST
18
matricola: ______________________________
nome (solo se non si ricorda la matricola):
__________________________________
- What is a closure? Why are closures necessary?
- Define a Scheme function F that takes as
input a predicate P? on natural numbers and returns a predicate on
lists of numbers that returns #t on a list ls if and only if P?
is true on all the elements of
ls.
Example: ((F odd?) (list 3 5 7) ) --> #t
(define (F P?)
(lambda (ls)
(or (null? ls)
(and (P? (car ls))
((F P?) (cdr ls))))))
- Describe the Environment at the end of the evaluation of the
following Scheme expression:
(let ((a 5))
( (lambda (y) (+ a 5) ) a ) )