#lang racket ; Same as notes04.rkt, but with connections to Notes 11 (define a 5000) (define b 600) (define c 70) (define (help) "help") (define (f x) (define (help) (+ x a b c)) (define a 1000) (define b 200) (define c 30) (help)) (f 4) ; 1. Loops to evaluate the exp in tail position of each pair. ; 2. Loops to create locations (making name available), assigning the matching exp value. ; 3. Evaluates the body. ; Duplicate identifiers are illegal. 'let (let ((f c) (c 999) (d c) (e b)) (list c d e f)) ; Simulation of the let special form ; http://docs.racket-lang.org/guide/let.html#%28part._.Parallel_.Binding__let%29 ; http://www.scheme.com/tspl4/binding.html#./binding:h4 ((lambda (f c d e) (list c d e f)) c 999 c b) ; 1. Loops over the pairs by evaluating the exp, create location, assigning value. ; 2. Evaluates the body. ; Duplicate identifiers are legal. 'let* (let* ((f c) (c 999) (d c) (e b)) (list c d e f)) ; Simulation of the let* special form ; http://docs.racket-lang.org/guide/let.html#%28part._.Sequential_.Binding__let_%29 ; http://www.scheme.com/tspl4/binding.html#./binding:h4 ((lambda (f) ((lambda (c) ((lambda (d) ((lambda (e) (list c d e f)) b)) c)) 999)) c) ; 1. Loops to create location for name in head position of each pair, ; assigning each the value #. ; 2. Loops over pairs to evaluate exp in tail position of each (new names are available), ; then assign value to name. ; 3. Evaluates the body. ; Duplicate identifiers are illegal. 'letrec (letrec ((f c) (c 999) (d c) (e b)) (list c d e f)) ; Simulation of the letrec special form ; http://docs.racket-lang.org/guide/let.html#%28part._.Recursive_.Binding__letrec%29 ; http://www.scheme.com/tspl4/binding.html#./binding:h4 ; http://docs.racket-lang.org/guide/void_undefined.html (define (undefined) (define undefined undefined) undefined) ((lambda (f c d e) (set! f c) (set! c 999) (set! d c) (set! e b) (list c d e f)) (undefined) (undefined) (undefined) (undefined))