Here is another way to get closer to it:
Write down the contract, purpose and title:
;; apply-double : function -> number -> any
;; to apply a given function to double a given number
(define (apply-double fun num) ...)
Write some tests:
(= (apply-double identity 10) 20)
(= (apply-double - 15) -30)
(= (apply-double / 7) 1/14)
Define a function:
(define (apply-double fun num)
(fun (* 2 num)))
This is the abbreviation for the recipe here: http://www.htdp.org/2003-09-26/Book/
source
share