sicp-ex-1.41


 (define (double f) 
         (lambda (x) (f (f x)))) 

The example given can be expanded in the following way:

 (((double (double double)) inc) 5) 
  
 (((double (lambda (x) (double (double x)))) inc) 5) 
  
 ; ... similar expansion omitted 
  
 ((double (double (double (double inc)))) 5) 
  
 ((double (double (double (lambda (x) (inc (inc x)))))) 5) 
  
 ; ... similar expansion omitted 
  
 (inc (inc (inc (inc (inc (inc (inc (inc (inc (inc (inc (inc (inc (inc (inc (inc 5)))))))))))))))) 
  
 ; ... reduction omitted 
  
 ;21 

<< Previous exercise (1.40) | Next exercise (1.42) >>