#reader(lib"read.ss""wxme")WXME0108 ## #| This file uses the GRacket editor format. Open this file in DrRacket version 5.3.6 or later to read it. Most likely, it was created by saving a program in DrRacket, and it probably contains a program with non-text elements (such as images or comment boxes). http://racket-lang.org/ |# 30 7 #"wxtext\0" 3 1 6 #"wxtab\0" 1 1 8 #"wximage\0" 2 0 8 #"wxmedia\0" 4 1 34 #"(lib \"syntax-browser.ss\" \"mrlib\")\0" 1 0 16 #"drscheme:number\0" 3 0 44 #"(lib \"number-snip.ss\" \"drscheme\" \"private\")\0" 1 0 36 #"(lib \"comment-snip.ss\" \"framework\")\0" 1 0 93 ( #"((lib \"collapsed-snipclass.ss\" \"framework\") (lib \"collapsed-sni" #"pclass-wxme.ss\" \"framework\"))\0" ) 0 0 43 #"(lib \"collapsed-snipclass.ss\" \"framework\")\0" 0 0 19 #"drscheme:sexp-snip\0" 0 0 36 #"(lib \"cache-image-snip.ss\" \"mrlib\")\0" 1 0 68 ( #"((lib \"image-core.ss\" \"mrlib\") (lib \"image-core-wxme.rkt\" \"mr" #"lib\"))\0" ) 1 0 29 #"drscheme:bindings-snipclass%\0" 1 0 88 ( #"((lib \"pict-snip.rkt\" \"drracket\" \"private\") (lib \"pict-snip.r" #"kt\" \"drracket\" \"private\"))\0" ) 0 0 33 #"(lib \"bullet-snip.ss\" \"browser\")\0" 0 0 25 #"(lib \"matrix.ss\" \"htdp\")\0" 1 0 22 #"drscheme:lambda-snip%\0" 1 0 26 #"drracket:spacer-snipclass\0" 0 0 57 #"(lib \"hrule-snip.rkt\" \"macro-debugger\" \"syntax-browser\")\0" 1 0 26 #"drscheme:pict-value-snip%\0" 0 0 45 #"(lib \"image-snipr.ss\" \"slideshow\" \"private\")\0" 1 0 38 #"(lib \"pict-snipclass.ss\" \"slideshow\")\0" 2 0 55 #"(lib \"vertical-separator-snip.ss\" \"stepper\" \"private\")\0" 1 0 18 #"drscheme:xml-snip\0" 1 0 31 #"(lib \"xml-snipclass.ss\" \"xml\")\0" 1 0 21 #"drscheme:scheme-snip\0" 2 0 34 #"(lib \"scheme-snipclass.ss\" \"xml\")\0" 1 0 10 #"text-box%\0" 1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0" 1 0 1 6 #"wxloc\0" 0 0 74 0 1 #"\0" 0 75 1 #"\0" 0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 9 #"Standard\0" 0 75 6 #"Menlo\0" 0 23 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 2 24 #"framework:default-color\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 15 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 15 #"text:ports out\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 255 0 0 0 0 0 -1 -1 2 15 #"text:ports err\0" 0 -1 1 #"\0" 1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 255 0 0 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 17 #"text:ports value\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1 -1 2 27 #"Matching Parenthesis Style\0" 0 -1 1 #"\0" 1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 38 38 128 0 0 0 -1 -1 2 37 #"framework:syntax-color:scheme:symbol\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 38 38 128 0 0 0 -1 -1 2 38 #"framework:syntax-color:scheme:keyword\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 38 38 128 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 12 21 194 0 0 0 -1 -1 2 38 #"framework:syntax-color:scheme:comment\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 12 21 194 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 41 128 38 0 0 0 -1 -1 2 37 #"framework:syntax-color:scheme:string\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 41 128 38 0 0 0 -1 -1 2 39 #"framework:syntax-color:scheme:constant\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 41 128 38 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 49 #"framework:syntax-color:scheme:hash-colon-keyword\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 42 #"framework:syntax-color:scheme:parenthesis\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0 0 -1 -1 2 36 #"framework:syntax-color:scheme:error\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0 -1 -1 2 36 #"framework:syntax-color:scheme:other\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0 -1 -1 2 16 #"Misspelled Text\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 81 112 203 0 0 0 -1 -1 2 38 #"drracket:check-syntax:lexically-bound\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 81 112 203 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 28 #"drracket:check-syntax:set!d\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 37 #"drracket:check-syntax:unused-require\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0 0 -1 -1 2 36 #"drracket:check-syntax:free-variable\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 68 0 203 0 0 0 -1 -1 2 31 #"drracket:check-syntax:imported\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 68 0 203 0 0 0 -1 -1 2 47 #"drracket:check-syntax:my-obligation-style-pref\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 116 0 0 0 0 -1 -1 2 50 #"drracket:check-syntax:their-obligation-style-pref\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 116 0 0 0 0 -1 -1 2 48 #"drracket:check-syntax:unk-obligation-style-pref\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 139 142 28 0 0 0 -1 -1 2 49 #"drracket:check-syntax:both-obligation-style-pref\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 139 142 28 0 0 0 -1 -1 2 26 #"plt:htdp:test-coverage-on\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0 -1 -1 2 1 #"\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 2 27 #"plt:htdp:test-coverage-off\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 4 1 #"\0" 0 70 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 -1 -1 4 4 #"XML\0" 0 70 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 -1 -1 2 37 #"plt:module-language:test-coverage-on\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0 -1 -1 2 38 #"plt:module-language:test-coverage-off\0" 0 -1 1 #"\0" 1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 0 1 #"\0" 0 75 6 #"Menlo\0" 0.0 23 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0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-1 0 1 #"\0" 0 75 6 #"Menlo\0" 0.0 13 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255 255 255 1 -1 0 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 0 -1 19 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 1 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255 255 255 -1 -1 0 315 0 4 3 85 ( #";; The first three lines of this file were inserted by DrRacket. The" #"y record metadata" ) 0 0 4 29 1 #"\n" 0 0 4 3 85 ( #";; about the language level of this file in a form that our tools ca" #"n easily process." ) 0 0 4 29 1 #"\n" 0 0 4 3 208 ( #"#reader(lib \"htdp-intermediate-lambda-reader.ss\" \"lang\")((modnam" #"e |#lect20-law-of-racket;-scope|) (read-case-sensitive #t) (teachpac" #"ks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none " #"#f ())))" ) 0 0 4 29 1 #"\n" 0 0 17 3 4 #";;;;" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 17 3 31 #"; The Law of Scheme/Racket/Lisp" 0 0 23 29 1 #"\n" 0 0 17 3 13 #"; lambda (\316\273)" 0 0 23 29 1 #"\n" 0 0 17 3 29 #"; let and friends (revisited)" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 17 3 2 #"#|" 0 0 17 29 1 #"\n" 0 0 17 3 33 #"In Racket, we have *expressions*;" 0 0 17 29 1 #"\n" 0 0 17 3 42 #"every expression *evaluates* to a *value*." 0 0 17 29 1 #"\n" 0 0 17 3 29 #"E.g. (+ 2 3) evaluates to 5" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 31 #"That's all(*) we do, in racket!" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 15 #"flip-horizontal" 0 0 17 29 1 #"\n" 0 0 17 3 29 #"An *expr* (syntax) is either:" 0 0 17 29 1 #"\n" 0 0 17 3 11 #" - a value" 0 0 17 29 1 #"\n" 0 0 17 3 17 #" - an identifier" 0 0 17 29 1 #"\n" 0 0 17 3 27 #" - a function-application:" 0 0 17 29 1 #"\n" 0 0 17 3 32 #" (expr_0 expr_1 ... expr_n)" 0 0 17 29 1 #"\n" 0 0 17 3 19 #" - a special form:" 0 0 17 29 1 #"\n" 0 0 17 3 22 #" - (define id expr)" 0 0 17 29 1 #"\n" 0 0 17 3 16 #" [Note that" 0 0 17 29 1 #"\n" 0 0 17 3 33 #" (define (id0 ... idn) expr)" 0 0 17 29 1 #"\n" 0 0 17 3 34 #" is just syntactic sugar for:" 0 0 17 29 1 #"\n" 0 0 17 3 45 #" (define id0 (\316\273 (id1 ... idn) expr)) ]" 0 0 17 29 1 #"\n" 0 0 17 3 29 #" - (cond [expr_q0 expr_a0]" 0 0 17 29 1 #"\n" 0 0 17 3 29 #" [expr_q1 expr_a1]" 0 0 17 29 1 #"\n" 0 0 17 3 15 #" ..." 0 0 17 29 1 #"\n" 0 0 17 3 30 #" [expr_qn expr_an])" 0 0 17 29 1 #"\n" 0 0 17 3 43 #" - if: (if expr_tst expr_thn expr_els)" 0 0 17 29 1 #"\n" 0 0 17 3 19 #" - define-struct" 0 0 17 29 1 #"\n" 0 0 17 3 9 #" - let" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 9 #"Examples:" 0 0 17 29 1 #"\n" 0 0 17 3 8 #"- values" 0 0 17 29 1 #"\n" 0 0 17 3 7 #" 17" 0 0 17 29 1 #"\n" 0 0 17 3 7 #" #t" 0 0 17 29 1 #"\n" 0 0 17 3 11 #" 'ehllo" 0 0 17 29 1 #"\n" 0 0 17 3 10 #" \"eh?\"" 0 0 17 29 1 #"\n" 0 0 17 3 10 #" empty" 0 0 17 29 1 #"\n" 0 0 17 3 21 #" (\316\273 (n) (* 3 n))" 0 0 17 29 1 #"\n" 0 0 17 3 13 #"- identifiers" 0 0 17 29 1 #"\n" 0 0 17 3 6 #" pi" 0 0 17 29 1 #"\n" 0 0 17 3 14 #" num-people" 0 0 17 29 1 #"\n" 0 0 17 3 5 #" +" 0 0 17 29 1 #"\n" 0 0 17 3 22 #"- function application" 0 0 17 29 1 #"\n" 0 0 17 3 9 #" (+ 2 3)" 0 0 17 29 1 #"\n" 0 0 17 3 11 #" (sqrt 23)" 0 0 17 29 1 #"\n" 0 0 17 3 28 #" (* 2 pi (sqrt 23) (+ 2 3))" 0 0 17 29 1 #"\n" 0 0 17 3 24 #" = (+ 2 3.14 4.87 5)" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 30 #"- let (see below for examples)" 0 0 17 29 1 #"\n" 0 0 17 3 1 #" " 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 10 #"Semantics:" 0 0 17 29 1 #"\n" 0 0 17 3 8 #"- values" 0 0 17 29 1 #"\n" 0 0 17 3 26 #" evaluate to themselves!" 0 0 17 29 1 #"\n" 0 0 17 3 13 #"- identifiers" 0 0 17 29 1 #"\n" 0 0 17 3 53 #" go find the corresponding `define`, use that value." 0 0 17 29 1 #"\n" 0 0 17 3 22 #"- function application" 0 0 17 29 1 #"\n" 0 0 17 3 32 #" (expr_0 expr_1 ... expr_n)" 0 0 17 29 1 #"\n" 0 0 17 3 67 #" Evaluate each expression, getting values val_0, val_1, ..., val_n" 0 0 17 29 1 #"\n" 0 0 17 3 39 #" Note: val_0 had better be a function!" 0 0 17 29 1 #"\n" 0 0 17 3 46 #" In the body of val_0, replace each parameter" 0 0 17 29 1 #"\n" 0 0 17 3 26 #" with val_1,..., val_n;" 0 0 17 29 1 #"\n" 0 0 17 3 39 #" evaluate that resulting expression." 0 0 17 29 1 #"\n" 0 0 17 3 16 #"- special forms:" 0 0 17 29 1 #"\n" 0 0 17 3 12 #" - define" 0 0 17 29 1 #"\n" 0 0 17 3 58 #" - cond: takes a *list* of question/answer expressions:" 0 0 17 29 1 #"\n" 0 0 17 3 39 #" -- (cond) evaluates to an error." 0 0 17 29 1 #"\n" 0 0 17 3 11 #" " 0 0 17 29 1 #"\n" 0 0 17 3 33 #" -- (cond [expr_q0 expr_a0]" 0 0 17 29 1 #"\n" 0 0 17 3 33 #" [expr_q1 expr_a1]" 0 0 17 29 1 #"\n" 0 0 17 3 19 #" ..." 0 0 17 29 1 #"\n" 0 0 17 3 34 #" [expr_qn expr_an])" 0 0 17 29 1 #"\n" 0 0 17 3 56 #" Evaluate expr_q0 (it had better be a boolean);" 0 0 17 29 1 #"\n" 0 0 17 3 39 #" if the value is true, then" 0 0 17 29 1 #"\n" 0 0 17 3 55 #" evaluate expr_a0 and return that result" 0 0 17 29 1 #"\n" 0 0 17 3 17 #" else" 0 0 17 29 1 #"\n" 0 0 17 3 48 #" return the result of evaluating:" 0 0 17 29 1 #"\n" 0 0 17 3 20 #" (cond" 0 0 17 29 1 #"\n" 0 0 17 3 33 #" [expr_q1 expr_a1]" 0 0 17 29 1 #"\n" 0 0 17 3 19 #" ..." 0 0 17 29 1 #"\n" 0 0 17 3 34 #" [expr_qn expr_an])" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 46 #" - if: (if expr_cond expr_then expr_else)" 0 0 17 29 1 #"\n" 0 0 17 11 73 ( #" evaluate expr_cond (it had better be a boolean); call the re" #"sult " ) 0 0 17 3 7 #"v_cond." 0 0 17 29 1 #"\n" 0 0 17 3 63 #" If v_cond is true, return result of eval'ing expr_then;" 0 0 17 29 1 #"\n" 0 0 17 3 53 #" otherwise return result of eval'ing expr_else" 0 0 17 29 1 #"\n" 0 0 17 3 8 #" " 0 0 17 29 1 #"\n" 0 0 17 3 72 ( #" alternately: the result of eval'ing `if` is syntactic sugar " #"for:" ) 0 0 17 29 1 #"\n" 0 0 17 3 30 #" the result of evaling" 0 0 17 29 1 #"\n" 0 0 17 3 39 #" (cond [expr_cond expr_then]" 0 0 17 29 1 #"\n" 0 0 17 3 35 #" [else expr_else])" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 14 #" - and, or" 0 0 17 29 1 #"\n" 0 0 17 3 20 #" - define-struct" 0 0 17 29 1 #"\n" 0 0 17 3 16 #" - let, let*" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 44 #" Hey: let's look more closely at functions:" 0 0 17 29 1 #"\n" 0 0 17 3 47 #" In \"function-application\" semantics, we say" 0 0 17 29 1 #"\n" 0 0 17 3 47 #" that the function-application simplifies to" 0 0 17 29 1 #"\n" 0 0 17 3 70 ( #" \"the body of the function, where parameters(identifiers) have b" #"een" ) 0 0 17 29 1 #"\n" 0 0 17 3 46 #" substituted with the arguments(values)\"" 0 0 17 29 1 #"\n" 0 0 17 3 29 #" But: what about the very " 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 29 1 #"\n" 0 0 17 3 28 #"(*) Okay, I'm fudging a bit:" 0 0 17 29 1 #"\n" 0 0 17 3 52 #"`define` isn't really an expression; you can't write" 0 0 17 29 1 #"\n" 0 0 17 3 27 #" (+ 7 (define x 99) 3)" 0 0 17 29 1 #"\n" 0 0 17 3 44 #"However, note that `let` *is* an expression," 0 0 17 29 1 #"\n" 0 0 17 3 63 #"and it's not too hard to imagine a world where your entire file" 0 0 17 29 1 #"\n" 0 0 17 3 38 #"is really surrounded by one big `let`." 0 0 17 29 1 #"\n" 0 0 17 3 58 #"...And we saw that `let` can be translated to a lambda ..." 0 0 17 29 1 #"\n" 0 0 17 3 62 #"...so can we make a language that doesn't use `define` at all," 0 0 17 29 1 #"\n" 0 0 17 3 35 #"just uses `lambda` and parameters? " 0 0 17 29 1 #"\n" 0 0 17 3 67 ( #"See: \"the lambda calculus\"; \"the Y combinator\"; \"church numeral" #"s\". " ) 0 0 17 29 1 #"\n" 0 0 17 3 2 #"|#" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 17 3 17 #";;; step through:" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 3 1 #"(" 0 0 15 3 6 #"define" 0 0 23 3 2 #" (" 0 0 14 3 3 #"sum" 0 0 23 3 1 #" " 0 0 14 3 4 #"nums" 0 0 23 3 1 #")" 0 0 23 29 1 #"\n" 0 0 23 3 3 #" (" 0 0 15 3 4 #"cond" 0 0 23 3 3 #" [(" 0 0 14 3 6 #"empty?" 0 0 23 3 1 #" " 0 0 14 3 4 #"nums" 0 0 23 3 2 #") " 0 0 20 3 1 #"0" 0 0 23 3 1 #"]" 0 0 23 29 1 #"\n" 0 0 23 3 10 #" [(" 0 0 14 3 5 #"cons?" 0 0 23 3 1 #" " 0 0 14 3 4 #"nums" 0 0 23 3 3 #") (" 0 0 14 3 1 #"+" 0 0 23 3 2 #" (" 0 0 14 3 5 #"first" 0 0 23 3 1 #" " 0 0 14 3 4 #"nums" 0 0 23 3 3 #") (" 0 0 14 3 3 #"sum" 0 0 23 3 2 #" (" 0 0 14 3 4 #"rest" 0 0 23 3 1 #" " 0 0 14 3 4 #"nums" 0 0 23 3 6 #")))]))" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 3 1 #"(" 0 0 14 3 3 #"sum" 0 0 23 3 2 #" (" 0 0 14 3 4 #"cons" 0 0 23 3 1 #" " 0 0 20 3 1 #"2" 0 0 23 3 2 #" (" 0 0 14 3 4 #"cons" 0 0 23 3 1 #" " 0 0 20 3 1 #"9" 0 0 23 3 2 #" (" 0 0 14 3 4 #"cons" 0 0 23 3 1 #" " 0 0 20 3 1 #"1" 0 0 23 3 2 #" (" 0 0 14 3 4 #"cons" 0 0 23 3 1 #" " 0 0 20 3 2 #"44" 0 0 23 3 1 #" " 0 0 14 3 5 #"empty" 0 0 23 3 5 #")))))" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 17 3 56 #";;; Note: we will *not* talk about tail-recursion yet --" 0 0 23 29 1 #"\n" 0 0 17 3 55 #";;; let's get more practice with regular ol' functions." 0 0 23 29 1 #"\n" 0 0 17 3 61 #";;; (But we can point out how the stack piles up, for `sum`.)" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0 23 29 1 #"\n" 0 0