i dont understand this code
Posted: Sun Oct 13, 2013 7:16 am
hy everyone, for homework i had to make a faculty function that used multiplication.
so i made this :
(define (fac a)
(if (= a 1)
1
(* a (fac (- a 1)))))
and it works, but the solution gave this :
(define (fac n)
(product (lambda (x) x) 1 (lambda (x) (+ x 1)) n))
and i dont understand what happens here, could someone explain for me?
many thanks, a beginning student
so i made this :
(define (fac a)
(if (= a 1)
1
(* a (fac (- a 1)))))
and it works, but the solution gave this :
(define (fac n)
(product (lambda (x) x) 1 (lambda (x) (+ x 1)) n))
and i dont understand what happens here, could someone explain for me?
many thanks, a beginning student