Define a procedure double that takes a procedure of one argument as argument and returns a procedure that applies the original procedure twice. For example, if inc is a procedure that adds 1 to its argument, then (double inc) should be a procedure that adds 2. What value is returned by

(((double (double double)) inc) 5)

There are no comments yet.

Authentication required

You must log in to post a comment.

(define (inc x)
  (+ x 1))

(define (square x)
  (* x x))

(check-equal? (((double (double double)) inc) 5) 21)
(check-equal? ((double inc) 6) 8)
(check-equal? ((double square) 3) 81)