Develop the function pi, which consumes a list of numbers and computes their product:
;; pi : Listof[Number] -> Number
;; compute the product of the numbers
(define (pi l)
(cond
[(empty? l) 1]
[else (* (first l) (pi (rest l)))]))
(equal? (pi (list 1 2 3) 6)
Solution
(define (pi l) (foldr * 1 l)) ;; [PT 2 -- 1 for pi, 1 for correct args]