I can't understand scheme define, lambda, let clearly -


recently started learning scheme language

but don't know how solve problem.

(define   (lambda()     (let* ((x 2)            (c (lambda (p)                 (let ((x 4))                   (p))))            (d (lambda ()                 x))            (b (lambda ()                 (let ((x 3))                   (c d)))))       b))) 

q. printed? how shallow binding , deep binding?

i briefly understand define, lambda, let* have no idea solve problem. how can solve it? please comment detailed explanation

the procedure returns procedure b. so

(a) 

returns

#<procedure:b> 

if want executed, have run

((a)) 

which whill call b , return

2 

so happening? calling b call c d parameter. c therefore call d (bound parameter p). d returns x printed whatever value bound x in procedure d. since scheme lexically scoped, , d not have binding x, binding of lexical context used, comes from

(let* ((x 2) 

which why 2 gets printed, regardless of other bindings d may exist in other procedures.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -