TEST
16
matricola: ______________________________
nome (solo se non si ricorda la matricola):
__________________________________
- Write a let expression whose semantics is equivalent to the
following
expression
((lambda (a b) (a b)) (lambda (x) x) 3)
- Define in Haskell the parametric data type (Stack a)
- Define (possibly without using any auxiliary
function) a Scheme function F that takes as input a predicate
'P?' on natural numbers and a natural number n . It returns a predicate
on natural numbers which it is true on m if and only if 'P?' is true at
least n times on the numbers between 0 and m.
Example: ((F odd? 2) 5) --> #t
(define (F P? n)
(lambda (m)
(cond ((= n 0) #t)
((= m 0) (and
(P? 0) (= n 1)))
((not (P? m))
((F P? n) (- m 1)))
(else ((F P? (-
n 1)) (- m 1))))))