Problem 3: Compose (100 pts)
Write the procedure composed
, which takes in procedures f
and g
and outputs a new procedure. This new procedure takes in a number x
and outputs the result of calling f
on g
of x
.
(define (composed f g)
'YOUR-CODE-HERE
)
;;; Tests
; scm> (define (add-one x) (+ x 1))
; add-one
; scm> (define (mul-two x) (* x 2))
; mul-two
; scm> (define mul-two-then-add-one (composed add-one mul-two))
; mul-two-then-add-one
; scm> (mul-two-then-add-one 2)
; 5