;;;
;;;
;;;
(
define (fact n)
(
if (= n 0)
1
(* n (fact (- n 1))) ) )
;;;
(verifier fact
(fact 1) == 1
(fact 2) == 2
(fact 4) == 24 )
;;;
;;;
;;;
;;;
;;;
;;;
;;;
(
define (map f liste)
;;
;;
(define (reduce f fin liste)
(
if (pair? liste)
(f (car liste)
;
(reduce f fin (cdr liste)) )
fin ) )
;;
;;
(define (composer element resultat)
(cons (f element) resultat) )
(reduce composer '() liste) )
;;;
;;;
;;;
(
define (identite x)
x )
(verifier map
(map identite '(a b c d)) == (append '(a b) '(c d))
(map car '((a 1)(b 2)(c 3)(d 4))) == (list 'a 'b 'c 'd) )