I am trying to translate this schema code into Javascript:
(define (double f)
(lambda (x) (f (f x))))
(define (inc x) (+ x 1))
((double inc) 0)
((double inc) 0)means (inc (inc 0))therefore it returns 2.
This is my Javascript code:
var double = function(f){
return function(x) { f(f(x)); }
}
var inc = function(x) {return x+1;}
double(inc)(0);
But it double(inc)(0)returns undefined, not 2. Why?
source
share