home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / schmrprt / r395rs.lha / prog.tex < prev    next >
LaTeX Document  |  1989-03-12  |  4.6 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: LaTeX Document (document/latex).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 63 68 61 70 74 65 72 | 7b 50 72 6f 67 72 61 6d |\chapter|{Program|
|00000010| 20 73 74 72 75 63 74 75 | 72 65 7d 0a 5c 6c 61 62 | structu|re}.\lab|
|00000020| 65 6c 7b 70 72 6f 67 72 | 61 6d 63 68 61 70 74 65 |el{progr|amchapte|
|00000030| 72 7d 0a 0a 5c 73 65 63 | 74 69 6f 6e 7b 50 72 6f |r}..\sec|tion{Pro|
|00000040| 67 72 61 6d 73 7d 0a 0a | 41 20 53 63 68 65 6d 65 |grams}..|A Scheme|
|00000050| 20 70 72 6f 67 72 61 6d | 20 63 6f 6e 73 69 73 74 | program| consist|
|00000060| 73 20 6f 66 20 61 20 73 | 65 71 75 65 6e 63 65 20 |s of a s|equence |
|00000070| 6f 66 20 65 78 70 72 65 | 73 73 69 6f 6e 73 20 61 |of expre|ssions a|
|00000080| 6e 64 20 64 65 66 69 6e | 69 74 69 6f 6e 73 2e 0a |nd defin|itions..|
|00000090| 45 78 70 72 65 73 73 69 | 6f 6e 73 20 61 72 65 20 |Expressi|ons are |
|000000a0| 64 65 73 63 72 69 62 65 | 64 20 69 6e 20 63 68 61 |describe|d in cha|
|000000b0| 70 74 65 72 7e 5c 72 65 | 66 7b 65 78 70 72 65 73 |pter~\re|f{expres|
|000000c0| 73 69 6f 6e 63 68 61 70 | 74 65 72 7d 3b 0a 64 65 |sionchap|ter};.de|
|000000d0| 66 69 6e 69 74 69 6f 6e | 73 20 61 72 65 20 74 68 |finition|s are th|
|000000e0| 65 20 73 75 62 6a 65 63 | 74 20 6f 66 20 74 68 65 |e subjec|t of the|
|000000f0| 20 72 65 73 74 20 6f 66 | 20 74 68 65 20 70 72 65 | rest of| the pre|
|00000100| 73 65 6e 74 20 63 68 61 | 70 74 65 72 2e 0a 0a 50 |sent cha|pter...P|
|00000110| 72 6f 67 72 61 6d 73 20 | 61 72 65 20 74 79 70 69 |rograms |are typi|
|00000120| 63 61 6c 6c 79 20 73 74 | 6f 72 65 64 20 69 6e 20 |cally st|ored in |
|00000130| 66 69 6c 65 73 20 6f 72 | 20 65 6e 74 65 72 65 64 |files or| entered|
|00000140| 20 69 6e 74 65 72 61 63 | 74 69 76 65 6c 79 20 74 | interac|tively t|
|00000150| 6f 20 61 0a 72 75 6e 6e | 69 6e 67 20 53 63 68 65 |o a.runn|ing Sche|
|00000160| 6d 65 20 73 79 73 74 65 | 6d 2c 20 61 6c 74 68 6f |me syste|m, altho|
|00000170| 75 67 68 20 6f 74 68 65 | 72 20 70 61 72 61 64 69 |ugh othe|r paradi|
|00000180| 67 6d 73 20 61 72 65 20 | 70 6f 73 73 69 62 6c 65 |gms are |possible|
|00000190| 3b 0a 71 75 65 73 74 69 | 6f 6e 73 20 6f 66 20 75 |;.questi|ons of u|
|000001a0| 73 65 72 20 69 6e 74 65 | 72 66 61 63 65 20 6c 69 |ser inte|rface li|
|000001b0| 65 20 6f 75 74 73 69 64 | 65 20 74 68 65 20 73 63 |e outsid|e the sc|
|000001c0| 6f 70 65 20 6f 66 20 74 | 68 69 73 20 72 65 70 6f |ope of t|his repo|
|000001d0| 72 74 2e 0a 28 49 6e 64 | 65 65 64 2c 20 53 63 68 |rt..(Ind|eed, Sch|
|000001e0| 65 6d 65 20 77 6f 75 6c | 64 20 73 74 69 6c 6c 20 |eme woul|d still |
|000001f0| 62 65 20 75 73 65 66 75 | 6c 20 61 73 20 61 20 6e |be usefu|l as a n|
|00000200| 6f 74 61 74 69 6f 6e 20 | 66 6f 72 20 65 78 70 72 |otation |for expr|
|00000210| 65 73 73 69 6e 67 0a 63 | 6f 6d 70 75 74 61 74 69 |essing.c|omputati|
|00000220| 6f 6e 61 6c 20 6d 65 74 | 68 6f 64 73 20 65 76 65 |onal met|hods eve|
|00000230| 6e 20 69 6e 20 74 68 65 | 20 61 62 73 65 6e 63 65 |n in the| absence|
|00000240| 20 6f 66 20 61 20 6d 65 | 63 68 61 6e 69 63 61 6c | of a me|chanical|
|00000250| 0a 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 2e |.impleme|ntation.|
|00000260| 29 0a 0a 44 65 66 69 6e | 69 74 69 6f 6e 73 20 6f |)..Defin|itions o|
|00000270| 63 63 75 72 72 69 6e 67 | 20 61 74 20 74 68 65 20 |ccurring| at the |
|00000280| 74 6f 70 20 6c 65 76 65 | 6c 20 6f 66 20 61 20 70 |top leve|l of a p|
|00000290| 72 6f 67 72 61 6d 20 63 | 61 6e 20 62 65 20 69 6e |rogram c|an be in|
|000002a0| 74 65 72 70 72 65 74 65 | 64 0a 64 65 63 6c 61 72 |terprete|d.declar|
|000002b0| 61 74 69 76 65 6c 79 2e | 20 20 54 68 65 79 20 63 |atively.| They c|
|000002c0| 61 75 73 65 20 62 69 6e | 64 69 6e 67 73 20 74 6f |ause bin|dings to|
|000002d0| 20 62 65 20 63 72 65 61 | 74 65 64 20 69 6e 20 74 | be crea|ted in t|
|000002e0| 68 65 20 74 6f 70 20 6c | 65 76 65 6c 0a 65 6e 76 |he top l|evel.env|
|000002f0| 69 72 6f 6e 6d 65 6e 74 | 2e 20 20 45 78 70 72 65 |ironment|. Expre|
|00000300| 73 73 69 6f 6e 73 20 6f | 63 63 75 72 72 69 6e 67 |ssions o|ccurring|
|00000310| 20 61 74 20 74 68 65 20 | 74 6f 70 20 6c 65 76 65 | at the |top leve|
|00000320| 6c 20 6f 66 20 61 20 70 | 72 6f 67 72 61 6d 20 61 |l of a p|rogram a|
|00000330| 72 65 0a 69 6e 74 65 72 | 70 72 65 74 65 64 20 69 |re.inter|preted i|
|00000340| 6d 70 65 72 61 74 69 76 | 65 6c 79 3b 20 74 68 65 |mperativ|ely; the|
|00000350| 79 20 61 72 65 20 65 78 | 65 63 75 74 65 64 20 69 |y are ex|ecuted i|
|00000360| 6e 20 6f 72 64 65 72 20 | 77 68 65 6e 20 74 68 65 |n order |when the|
|00000370| 20 70 72 6f 67 72 61 6d | 20 69 73 0a 69 6e 76 6f | program| is.invo|
|00000380| 6b 65 64 20 6f 72 20 6c | 6f 61 64 65 64 2c 20 61 |ked or l|oaded, a|
|00000390| 6e 64 20 74 79 70 69 63 | 61 6c 6c 79 20 70 65 72 |nd typic|ally per|
|000003a0| 66 6f 72 6d 20 73 6f 6d | 65 20 6b 69 6e 64 20 6f |form som|e kind o|
|000003b0| 66 20 69 6e 69 74 69 61 | 6c 69 7a 61 74 69 6f 6e |f initia|lization|
|000003c0| 2e 0a 0a 5c 74 6f 64 6f | 7b 43 72 6f 6d 61 72 74 |...\todo|{Cromart|
|000003d0| 79 2c 20 65 74 63 2e 3a | 20 64 69 73 63 6c 61 69 |y, etc.:| disclai|
|000003e0| 6d 65 72 20 61 62 6f 75 | 74 20 74 6f 70 20 6c 65 |mer abou|t top le|
|000003f0| 76 65 6c 3f 7d 0a 0a 0a | 5c 73 65 63 74 69 6f 6e |vel?}...|\section|
|00000400| 7b 44 65 66 69 6e 69 74 | 69 6f 6e 73 7d 0a 0a 44 |{Definit|ions}..D|
|00000410| 65 66 69 6e 69 74 69 6f | 6e 73 20 61 72 65 20 76 |efinitio|ns are v|
|00000420| 61 6c 69 64 20 69 6e 20 | 73 6f 6d 65 2c 20 62 75 |alid in |some, bu|
|00000430| 74 20 6e 6f 74 20 61 6c | 6c 2c 20 63 6f 6e 74 65 |t not al|l, conte|
|00000440| 78 74 73 20 77 68 65 72 | 65 20 65 78 70 72 65 73 |xts wher|e expres|
|00000450| 73 69 6f 6e 73 0a 61 72 | 65 20 61 6c 6c 6f 77 65 |sions.ar|e allowe|
|00000460| 64 2e 20 20 54 68 65 79 | 20 61 72 65 20 76 61 6c |d. They| are val|
|00000470| 69 64 20 6f 6e 6c 79 20 | 61 74 20 74 68 65 20 74 |id only |at the t|
|00000480| 6f 70 20 6c 65 76 65 6c | 20 6f 66 20 61 20 5c 68 |op level| of a \h|
|00000490| 79 70 65 72 7b 70 72 6f | 67 72 61 6d 7d 0a 61 6e |yper{pro|gram}.an|
|000004a0| 64 2c 20 69 6e 20 73 6f | 6d 65 20 69 6d 70 6c 65 |d, in so|me imple|
|000004b0| 6d 65 6e 74 61 74 69 6f | 6e 73 2c 20 61 74 20 74 |mentatio|ns, at t|
|000004c0| 68 65 20 62 65 67 69 6e | 6e 69 6e 67 20 6f 66 20 |he begin|ning of |
|000004d0| 61 20 5c 68 79 70 65 72 | 7b 62 6f 64 79 7d 2e 0a |a \hyper|{body}..|
|000004e0| 0a 41 20 64 65 66 69 6e | 69 74 69 6f 6e 20 73 68 |.A defin|ition sh|
|000004f0| 6f 75 6c 64 20 68 61 76 | 65 20 6f 6e 65 20 6f 66 |ould hav|e one of|
|00000500| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 66 | the fol|lowing f|
|00000510| 6f 72 6d 73 3a 5c 6d 61 | 69 6e 73 63 68 69 6e 64 |orms:\ma|inschind|
|00000520| 65 78 7b 64 65 66 69 6e | 65 7d 0a 0a 5c 62 65 67 |ex{defin|e}..\beg|
|00000530| 69 6e 7b 69 74 65 6d 69 | 7a 65 7d 0a 0a 5c 69 74 |in{itemi|ze}..\it|
|00000540| 65 6d 20 7b 5c 74 74 28 | 64 65 66 69 6e 65 20 5c |em {\tt(|define \|
|00000550| 68 79 70 65 72 7b 76 61 | 72 69 61 62 6c 65 7d 20 |hyper{va|riable} |
|00000560| 5c 68 79 70 65 72 7b 65 | 78 70 72 65 73 73 69 6f |\hyper{e|xpressio|
|00000570| 6e 7d 29 7d 0a 0a 54 68 | 69 73 20 73 79 6e 74 61 |n})}..Th|is synta|
|00000580| 78 20 69 73 20 65 73 73 | 65 6e 74 69 61 6c 2e 0a |x is ess|ential..|
|00000590| 0a 5c 69 74 65 6d 7b 5c | 74 74 28 64 65 66 69 6e |.\item{\|tt(defin|
|000005a0| 65 20 28 5c 68 79 70 65 | 72 7b 76 61 72 69 61 62 |e (\hype|r{variab|
|000005b0| 6c 65 7d 20 5c 68 79 70 | 65 72 7b 66 6f 72 6d 61 |le} \hyp|er{forma|
|000005c0| 6c 73 7d 29 20 5c 68 79 | 70 65 72 7b 62 6f 64 79 |ls}) \hy|per{body|
|000005d0| 7d 29 7d 0a 0a 54 68 69 | 73 20 73 79 6e 74 61 78 |})}..Thi|s syntax|
|000005e0| 20 69 73 20 6e 6f 74 20 | 65 73 73 65 6e 74 69 61 | is not |essentia|
|000005f0| 6c 2e 20 20 5c 68 79 70 | 65 72 7b 46 6f 72 6d 61 |l. \hyp|er{Forma|
|00000600| 6c 73 7d 20 73 68 6f 75 | 6c 64 20 62 65 20 65 69 |ls} shou|ld be ei|
|00000610| 74 68 65 72 20 61 0a 73 | 65 71 75 65 6e 63 65 20 |ther a.s|equence |
|00000620| 6f 66 20 7a 65 72 6f 20 | 6f 72 20 6d 6f 72 65 20 |of zero |or more |
|00000630| 76 61 72 69 61 62 6c 65 | 73 2c 20 6f 72 20 61 20 |variable|s, or a |
|00000640| 73 65 71 75 65 6e 63 65 | 20 6f 66 20 6f 6e 65 20 |sequence| of one |
|00000650| 6f 72 20 6d 6f 72 65 0a | 76 61 72 69 61 62 6c 65 |or more.|variable|
|00000660| 73 20 66 6f 6c 6c 6f 77 | 65 64 20 62 79 20 61 20 |s follow|ed by a |
|00000670| 73 70 61 63 65 2d 64 65 | 6c 69 6d 69 74 65 64 20 |space-de|limited |
|00000680| 70 65 72 69 6f 64 20 61 | 6e 64 20 61 6e 6f 74 68 |period a|nd anoth|
|00000690| 65 72 20 76 61 72 69 61 | 62 6c 65 20 28 61 73 0a |er varia|ble (as.|
|000006a0| 69 6e 20 61 20 6c 61 6d | 62 64 61 20 65 78 70 72 |in a lam|bda expr|
|000006b0| 65 73 73 69 6f 6e 29 2e | 20 20 54 68 69 73 20 66 |ession).| This f|
|000006c0| 6f 72 6d 20 69 73 20 65 | 71 75 69 76 61 6c 65 6e |orm is e|quivalen|
|000006d0| 74 20 74 6f 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |t to.\be|gin{sche|
|000006e0| 6d 65 7d 0a 28 64 65 66 | 69 6e 65 20 5c 68 79 70 |me}.(def|ine \hyp|
|000006f0| 65 72 7b 76 61 72 69 61 | 62 6c 65 7d 0a 20 20 28 |er{varia|ble}. (|
|00000700| 6c 61 6d 62 64 61 20 28 | 5c 68 79 70 65 72 7b 66 |lambda (|\hyper{f|
|00000710| 6f 72 6d 61 6c 73 7d 29 | 20 5c 68 79 70 65 72 7b |ormals})| \hyper{|
|00000720| 62 6f 64 79 7d 29 29 5c | 72 6d 2e 25 0a 5c 65 6e |body}))\|rm.%.\en|
|00000730| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 5c 69 74 65 6d |d{scheme|}..\item|
|00000740| 7b 5c 74 74 28 64 65 66 | 69 6e 65 20 28 5c 68 79 |{\tt(def|ine (\hy|
|00000750| 70 65 72 7b 76 61 72 69 | 61 62 6c 65 7d 20 2e 5c |per{vari|able} .\|
|00000760| 20 5c 68 79 70 65 72 7b | 66 6f 72 6d 61 6c 7d 29 | \hyper{|formal})|
|00000770| 20 5c 68 79 70 65 72 7b | 62 6f 64 79 7d 29 7d 0a | \hyper{|body})}.|
|00000780| 0a 54 68 69 73 20 73 79 | 6e 74 61 78 20 69 73 20 |.This sy|ntax is |
|00000790| 6e 6f 74 20 65 73 73 65 | 6e 74 69 61 6c 2e 20 20 |not esse|ntial. |
|000007a0| 5c 68 79 70 65 72 7b 46 | 6f 72 6d 61 6c 7d 20 73 |\hyper{F|ormal} s|
|000007b0| 68 6f 75 6c 64 20 62 65 | 20 61 20 73 69 6e 67 6c |hould be| a singl|
|000007c0| 65 0a 76 61 72 69 61 62 | 6c 65 2e 20 20 54 68 69 |e.variab|le. Thi|
|000007d0| 73 20 66 6f 72 6d 20 69 | 73 20 65 71 75 69 76 61 |s form i|s equiva|
|000007e0| 6c 65 6e 74 20 74 6f 0a | 5c 62 65 67 69 6e 7b 73 |lent to.|\begin{s|
|000007f0| 63 68 65 6d 65 7d 0a 28 | 64 65 66 69 6e 65 20 5c |cheme}.(|define \|
|00000800| 68 79 70 65 72 7b 76 61 | 72 69 61 62 6c 65 7d 0a |hyper{va|riable}.|
|00000810| 20 20 28 6c 61 6d 62 64 | 61 20 5c 68 79 70 65 72 | (lambd|a \hyper|
|00000820| 7b 66 6f 72 6d 61 6c 7d | 20 5c 68 79 70 65 72 7b |{formal}| \hyper{|
|00000830| 62 6f 64 79 7d 29 29 5c | 72 6d 2e 25 0a 5c 65 6e |body}))\|rm.%.\en|
|00000840| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 5c 69 74 65 6d |d{scheme|}..\item|
|00000850| 20 7b 5c 74 74 28 62 65 | 67 69 6e 20 5c 68 79 70 | {\tt(be|gin \hyp|
|00000860| 65 72 69 7b 64 65 66 69 | 6e 69 74 69 6f 6e 7d 20 |eri{defi|nition} |
|00000870| 5c 64 6f 74 73 66 6f 6f | 29 7d 0a 0a 54 68 69 73 |\dotsfoo|)}..This|
|00000880| 20 73 79 6e 74 61 78 20 | 69 73 20 65 73 73 65 6e | syntax |is essen|
|00000890| 74 69 61 6c 2e 20 20 54 | 68 69 73 20 66 6f 72 6d |tial. T|his form|
|000008a0| 20 69 73 20 65 71 75 69 | 76 61 6c 65 6e 74 20 74 | is equi|valent t|
|000008b0| 6f 20 74 68 65 20 73 65 | 74 20 6f 66 0a 64 65 66 |o the se|t of.def|
|000008c0| 69 6e 69 74 69 6f 6e 73 | 20 74 68 61 74 20 66 6f |initions| that fo|
|000008d0| 72 6d 20 74 68 65 20 62 | 6f 64 79 20 6f 66 20 74 |rm the b|ody of t|
|000008e0| 68 65 20 5c 69 64 65 7b | 62 65 67 69 6e 7d 2e 0a |he \ide{|begin}..|
|000008f0| 0a 5c 65 6e 64 7b 69 74 | 65 6d 69 7a 65 7d 0a 0a |.\end{it|emize}..|
|00000900| 0a 5c 73 75 62 73 65 63 | 74 69 6f 6e 7b 54 6f 70 |.\subsec|tion{Top|
|00000910| 20 6c 65 76 65 6c 20 64 | 65 66 69 6e 69 74 69 6f | level d|efinitio|
|00000920| 6e 73 7d 0a 0a 41 74 20 | 74 68 65 20 74 6f 70 20 |ns}..At |the top |
|00000930| 6c 65 76 65 6c 20 6f 66 | 20 61 20 70 72 6f 67 72 |level of| a progr|
|00000940| 61 6d 2c 20 61 20 64 65 | 66 69 6e 69 74 69 6f 6e |am, a de|finition|
|00000950| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00000960| 28 64 65 66 69 6e 65 20 | 5c 68 79 70 65 72 7b 76 |(define |\hyper{v|
|00000970| 61 72 69 61 62 6c 65 7d | 20 5c 68 79 70 65 72 7b |ariable}| \hyper{|
|00000980| 65 78 70 72 65 73 73 69 | 6f 6e 7d 29 25 0a 5c 65 |expressi|on})%.\e|
|00000990| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 68 61 73 20 65 |nd{schem|e}.has e|
|000009a0| 73 73 65 6e 74 69 61 6c | 6c 79 20 74 68 65 20 73 |ssential|ly the s|
|000009b0| 61 6d 65 20 65 66 66 65 | 63 74 20 61 73 20 74 68 |ame effe|ct as th|
|000009c0| 65 20 61 73 73 69 67 6e | 6d 65 6e 74 20 65 78 70 |e assign|ment exp|
|000009d0| 72 65 73 73 69 6f 6e 0a | 5c 62 65 67 69 6e 7b 73 |ression.|\begin{s|
|000009e0| 63 68 65 6d 65 7d 0a 28 | 5c 69 64 65 7b 73 65 74 |cheme}.(|\ide{set|
|000009f0| 21 7d 5c 20 5c 68 79 70 | 65 72 7b 76 61 72 69 61 |!}\ \hyp|er{varia|
|00000a00| 62 6c 65 7d 20 5c 68 79 | 70 65 72 7b 65 78 70 72 |ble} \hy|per{expr|
|00000a10| 65 73 73 69 6f 6e 7d 29 | 25 0a 5c 65 6e 64 7b 73 |ession})|%.\end{s|
|00000a20| 63 68 65 6d 65 7d 0a 69 | 66 20 5c 68 79 70 65 72 |cheme}.i|f \hyper|
|00000a30| 7b 76 61 72 69 61 62 6c | 65 7d 20 69 73 20 62 6f |{variabl|e} is bo|
|00000a40| 75 6e 64 2e 20 20 49 66 | 20 5c 68 79 70 65 72 7b |und. If| \hyper{|
|00000a50| 76 61 72 69 61 62 6c 65 | 7d 20 69 73 20 6e 6f 74 |variable|} is not|
|00000a60| 20 62 6f 75 6e 64 2c 0a | 68 6f 77 65 76 65 72 2c | bound,.|however,|
|00000a70| 20 74 68 65 6e 20 74 68 | 65 20 64 65 66 69 6e 69 | then th|e defini|
|00000a80| 74 69 6f 6e 20 77 69 6c | 6c 20 62 69 6e 64 20 5c |tion wil|l bind \|
|00000a90| 68 79 70 65 72 7b 76 61 | 72 69 61 62 6c 65 7d 20 |hyper{va|riable} |
|00000aa0| 74 6f 20 61 20 6e 65 77 | 0a 6c 6f 63 61 74 69 6f |to a new|.locatio|
|00000ab0| 6e 20 62 65 66 6f 72 65 | 20 70 65 72 66 6f 72 6d |n before| perform|
|00000ac0| 69 6e 67 20 74 68 65 20 | 61 73 73 69 67 6e 6d 65 |ing the |assignme|
|00000ad0| 6e 74 2c 20 77 68 65 72 | 65 61 73 20 69 74 20 77 |nt, wher|eas it w|
|00000ae0| 6f 75 6c 64 20 62 65 20 | 61 6e 20 65 72 72 6f 72 |ould be |an error|
|00000af0| 0a 74 6f 20 70 65 72 66 | 6f 72 6d 20 61 20 5c 69 |.to perf|orm a \i|
|00000b00| 64 65 7b 73 65 74 21 7d | 5c 20 6f 6e 20 61 6e 20 |de{set!}|\ on an |
|00000b10| 75 6e 62 6f 75 6e 64 5c | 69 6e 64 65 78 7b 75 6e |unbound\|index{un|
|00000b20| 62 6f 75 6e 64 7d 20 76 | 61 72 69 61 62 6c 65 2e |bound} v|ariable.|
|00000b30| 0a 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |..\begin|{scheme}|
|00000b40| 0a 28 64 65 66 69 6e 65 | 20 61 64 64 33 0a 20 20 |.(define| add3. |
|00000b50| 28 6c 61 6d 62 64 61 20 | 28 78 29 20 28 2b 20 78 |(lambda |(x) (+ x|
|00000b60| 20 33 29 29 29 0a 28 61 | 64 64 33 20 33 29 20 20 | 3))).(a|dd3 3) |
|00000b70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000b80| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 36 | | \ev 6|
|00000b90| 0a 28 64 65 66 69 6e 65 | 20 66 69 72 73 74 20 63 |.(define| first c|
|00000ba0| 61 72 29 0a 28 66 69 72 | 73 74 20 27 28 31 20 32 |ar).(fir|st '(1 2|
|00000bb0| 29 29 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |)) | |
|00000bc0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 31 25 0a | |\ev 1%.|
|00000bd0| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 41 6c |\end{sch|eme}..Al|
|00000be0| 6c 20 53 63 68 65 6d 65 | 20 69 6d 70 6c 65 6d 65 |l Scheme| impleme|
|00000bf0| 6e 74 61 74 69 6f 6e 73 | 20 6d 75 73 74 20 73 75 |ntations| must su|
|00000c00| 70 70 6f 72 74 20 74 6f | 70 20 6c 65 76 65 6c 20 |pport to|p level |
|00000c10| 64 65 66 69 6e 69 74 69 | 6f 6e 73 2e 0a 0a 53 6f |definiti|ons...So|
|00000c20| 6d 65 20 69 6d 70 6c 65 | 6d 65 6e 74 61 74 69 6f |me imple|mentatio|
|00000c30| 6e 73 20 6f 66 20 53 63 | 68 65 6d 65 20 75 73 65 |ns of Sc|heme use|
|00000c40| 20 61 6e 20 69 6e 69 74 | 69 61 6c 20 65 6e 76 69 | an init|ial envi|
|00000c50| 72 6f 6e 6d 65 6e 74 20 | 69 6e 0a 77 68 69 63 68 |ronment |in.which|
|00000c60| 20 61 6c 6c 20 70 6f 73 | 73 69 62 6c 65 20 76 61 | all pos|sible va|
|00000c70| 72 69 61 62 6c 65 73 20 | 61 72 65 20 62 6f 75 6e |riables |are boun|
|00000c80| 64 20 74 6f 20 6c 6f 63 | 61 74 69 6f 6e 73 2c 20 |d to loc|ations, |
|00000c90| 6d 6f 73 74 20 6f 66 0a | 77 68 69 63 68 20 63 6f |most of.|which co|
|00000ca0| 6e 74 61 69 6e 20 75 6e | 64 65 66 69 6e 65 64 20 |ntain un|defined |
|00000cb0| 76 61 6c 75 65 73 2e 20 | 20 54 6f 70 20 6c 65 76 |values. | Top lev|
|00000cc0| 65 6c 20 64 65 66 69 6e | 69 74 69 6f 6e 73 20 69 |el defin|itions i|
|00000cd0| 6e 0a 73 75 63 68 20 61 | 6e 20 69 6d 70 6c 65 6d |n.such a|n implem|
|00000ce0| 65 6e 74 61 74 69 6f 6e | 20 61 72 65 20 74 72 75 |entation| are tru|
|00000cf0| 6c 79 20 65 71 75 69 76 | 61 6c 65 6e 74 20 74 6f |ly equiv|alent to|
|00000d00| 20 61 73 73 69 67 6e 6d | 65 6e 74 73 2e 0a 0a 5c | assignm|ents...\|
|00000d10| 74 6f 64 6f 7b 52 6f 7a | 61 73 3a 20 65 71 75 61 |todo{Roz|as: equa|
|00000d20| 6c 20 74 69 6d 65 20 66 | 6f 72 20 6f 70 70 6f 73 |l time f|or oppos|
|00000d30| 69 74 69 6f 6e 20 73 65 | 6d 61 6e 74 69 63 73 3f |ition se|mantics?|
|00000d40| 7d 0a 0a 0a 5c 73 75 62 | 73 65 63 74 69 6f 6e 7b |}...\sub|section{|
|00000d50| 49 6e 74 65 72 6e 61 6c | 20 64 65 66 69 6e 69 74 |Internal| definit|
|00000d60| 69 6f 6e 73 7d 0a 5c 6c | 61 62 65 6c 7b 69 6e 74 |ions}.\l|abel{int|
|00000d70| 65 72 6e 61 6c 64 65 66 | 69 6e 65 73 7d 0a 0a 53 |ernaldef|ines}..S|
|00000d80| 6f 6d 65 20 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |ome impl|ementati|
|00000d90| 6f 6e 73 20 6f 66 20 53 | 63 68 65 6d 65 20 70 65 |ons of S|cheme pe|
|00000da0| 72 6d 69 74 20 64 65 66 | 69 6e 69 74 69 6f 6e 73 |rmit def|initions|
|00000db0| 20 74 6f 20 6f 63 63 75 | 72 20 61 74 20 74 68 65 | to occu|r at the|
|00000dc0| 0a 62 65 67 69 6e 6e 69 | 6e 67 20 6f 66 20 61 20 |.beginni|ng of a |
|00000dd0| 5c 68 79 70 65 72 7b 62 | 6f 64 79 7d 20 28 74 68 |\hyper{b|ody} (th|
|00000de0| 61 74 20 69 73 2c 20 74 | 68 65 20 62 6f 64 79 20 |at is, t|he body |
|00000df0| 6f 66 20 61 20 5c 69 64 | 65 7b 6c 61 6d 62 64 61 |of a \id|e{lambda|
|00000e00| 7d 2c 0a 5c 69 64 65 7b | 6c 65 74 7d 2c 20 5c 69 |},.\ide{|let}, \i|
|00000e10| 64 65 7b 6c 65 74 2a 7d | 2c 20 5c 69 64 65 7b 6c |de{let*}|, \ide{l|
|00000e20| 65 74 72 65 63 7d 2c 20 | 6f 72 20 5c 69 64 65 7b |etrec}, |or \ide{|
|00000e30| 64 65 66 69 6e 65 7d 20 | 65 78 70 72 65 73 73 69 |define} |expressi|
|00000e40| 6f 6e 29 2e 20 20 53 75 | 63 68 0a 64 65 66 69 6e |on). Su|ch.defin|
|00000e50| 69 74 69 6f 6e 73 20 61 | 72 65 20 6b 6e 6f 77 6e |itions a|re known|
|00000e60| 20 61 73 20 7b 5c 65 6d | 20 69 6e 74 65 72 6e 61 | as {\em| interna|
|00000e70| 6c 20 64 65 66 69 6e 69 | 74 69 6f 6e 73 7d 20 5c |l defini|tions} \|
|00000e80| 6d 61 69 6e 69 6e 64 65 | 78 7b 69 6e 74 65 72 6e |maininde|x{intern|
|00000e90| 61 6c 0a 64 65 66 69 6e | 69 74 69 6f 6e 7d 20 61 |al.defin|ition} a|
|00000ea0| 73 20 6f 70 70 6f 73 65 | 64 20 74 6f 20 74 68 65 |s oppose|d to the|
|00000eb0| 20 74 6f 70 20 6c 65 76 | 65 6c 20 64 65 66 69 6e | top lev|el defin|
|00000ec0| 69 74 69 6f 6e 73 20 64 | 65 73 63 72 69 62 65 64 |itions d|escribed|
|00000ed0| 20 61 62 6f 76 65 2e 0a | 54 68 65 20 76 61 72 69 | above..|The vari|
|00000ee0| 61 62 6c 65 20 64 65 66 | 69 6e 65 64 20 62 79 20 |able def|ined by |
|00000ef0| 61 6e 20 69 6e 74 65 72 | 6e 61 6c 20 64 65 66 69 |an inter|nal defi|
|00000f00| 6e 69 74 69 6f 6e 20 69 | 73 20 6c 6f 63 61 6c 20 |nition i|s local |
|00000f10| 74 6f 20 74 68 65 0a 5c | 68 79 70 65 72 7b 62 6f |to the.\|hyper{bo|
|00000f20| 64 79 7d 2e 20 20 54 68 | 61 74 20 69 73 2c 20 5c |dy}. Th|at is, \|
|00000f30| 68 79 70 65 72 7b 76 61 | 72 69 61 62 6c 65 7d 20 |hyper{va|riable} |
|00000f40| 69 73 20 62 6f 75 6e 64 | 20 72 61 74 68 65 72 20 |is bound| rather |
|00000f50| 74 68 61 6e 20 61 73 73 | 69 67 6e 65 64 2c 0a 61 |than ass|igned,.a|
|00000f60| 6e 64 20 74 68 65 20 72 | 65 67 69 6f 6e 20 6f 66 |nd the r|egion of|
|00000f70| 20 74 68 65 20 62 69 6e | 64 69 6e 67 20 69 73 20 | the bin|ding is |
|00000f80| 74 68 65 20 65 6e 74 69 | 72 65 20 5c 68 79 70 65 |the enti|re \hype|
|00000f90| 72 7b 62 6f 64 79 7d 2e | 20 20 46 6f 72 20 65 78 |r{body}.| For ex|
|00000fa0| 61 6d 70 6c 65 2c 0a 0a | 5c 62 65 67 69 6e 7b 73 |ample,..|\begin{s|
|00000fb0| 63 68 65 6d 65 7d 0a 28 | 6c 65 74 20 28 28 78 20 |cheme}.(|let ((x |
|00000fc0| 35 29 29 0a 20 20 28 64 | 65 66 69 6e 65 20 66 6f |5)). (d|efine fo|
|00000fd0| 6f 20 28 6c 61 6d 62 64 | 61 20 28 79 29 20 28 62 |o (lambd|a (y) (b|
|00000fe0| 61 72 20 78 20 79 29 29 | 29 0a 20 20 28 64 65 66 |ar x y))|). (def|
|00000ff0| 69 6e 65 20 62 61 72 20 | 28 6c 61 6d 62 64 61 20 |ine bar |(lambda |
|00001000| 28 61 20 62 29 20 28 2b | 20 28 2a 20 61 20 62 29 |(a b) (+| (* a b)|
|00001010| 20 61 29 29 29 0a 20 20 | 28 66 6f 6f 20 28 2b 20 | a))). |(foo (+ |
|00001020| 78 20 33 29 29 29 20 20 | 20 20 20 20 20 20 20 20 |x 3))) | |
|00001030| 20 20 20 20 20 20 5c 65 | 76 20 20 34 35 25 0a 5c | \e|v 45%.\|
|00001040| 65 6e 64 7b 73 63 68 65 | 6d 65 7d 0a 0a 41 20 5c |end{sche|me}..A \|
|00001050| 68 79 70 65 72 7b 62 6f | 64 79 7d 20 63 6f 6e 74 |hyper{bo|dy} cont|
|00001060| 61 69 6e 69 6e 67 20 69 | 6e 74 65 72 6e 61 6c 20 |aining i|nternal |
|00001070| 64 65 66 69 6e 69 74 69 | 6f 6e 73 20 63 61 6e 20 |definiti|ons can |
|00001080| 61 6c 77 61 79 73 20 62 | 65 20 63 6f 6e 76 65 72 |always b|e conver|
|00001090| 74 65 64 0a 69 6e 74 6f | 20 61 20 63 6f 6d 70 6c |ted.into| a compl|
|000010a0| 65 74 65 6c 79 20 65 71 | 75 69 76 61 6c 65 6e 74 |etely eq|uivalent|
|000010b0| 20 5c 69 64 65 7b 6c 65 | 74 72 65 63 7d 20 65 78 | \ide{le|trec} ex|
|000010c0| 70 72 65 73 73 69 6f 6e | 2e 20 20 46 6f 72 20 65 |pression|. For e|
|000010d0| 78 61 6d 70 6c 65 2c 20 | 74 68 65 0a 5c 69 64 65 |xample, |the.\ide|
|000010e0| 7b 6c 65 74 7d 20 65 78 | 70 72 65 73 73 69 6f 6e |{let} ex|pression|
|000010f0| 20 69 6e 20 74 68 65 20 | 61 62 6f 76 65 20 65 78 | in the |above ex|
|00001100| 61 6d 70 6c 65 20 69 73 | 20 65 71 75 69 76 61 6c |ample is| equival|
|00001110| 65 6e 74 20 74 6f 0a 0a | 5c 62 65 67 69 6e 7b 73 |ent to..|\begin{s|
|00001120| 63 68 65 6d 65 7d 0a 28 | 6c 65 74 20 28 28 78 20 |cheme}.(|let ((x |
|00001130| 35 29 29 0a 20 20 28 6c | 65 74 72 65 63 20 28 28 |5)). (l|etrec ((|
|00001140| 66 6f 6f 20 28 6c 61 6d | 62 64 61 20 28 79 29 20 |foo (lam|bda (y) |
|00001150| 28 62 61 72 20 78 20 79 | 29 29 29 0a 20 20 20 20 |(bar x y|))). |
|00001160| 20 20 20 20 20 20 20 28 | 62 61 72 20 28 6c 61 6d | (|bar (lam|
|00001170| 62 64 61 20 28 61 20 62 | 29 20 28 2b 20 28 2a 20 |bda (a b|) (+ (* |
|00001180| 61 20 62 29 20 61 29 29 | 29 29 0a 20 20 20 20 28 |a b) a))|)). (|
|00001190| 66 6f 6f 20 28 2b 20 78 | 20 33 29 29 29 29 25 0a |foo (+ x| 3))))%.|
|000011a0| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 5c 74 |\end{sch|eme}..\t|
|000011b0| 6f 64 6f 7b 53 61 79 20 | 73 6f 6d 65 74 68 69 6e |odo{Say |somethin|
|000011c0| 67 20 61 62 6f 75 74 20 | 77 68 79 20 64 65 66 69 |g about |why defi|
|000011d0| 6e 69 74 69 6f 6e 73 20 | 61 72 65 6e 27 74 20 61 |nitions |aren't a|
|000011e0| 6c 6c 6f 77 65 64 20 69 | 6e 20 73 65 71 75 65 6e |llowed i|n sequen|
|000011f0| 63 65 0a 65 78 70 72 65 | 73 73 69 6f 6e 73 3f 20 |ce.expre|ssions? |
|00001200| 20 28 46 6f 72 20 6d 61 | 63 72 6f 73 2c 20 61 2e | (For ma|cros, a.|
|00001210| 6b 2e 61 2e 7e 74 68 65 | 20 60 60 7b 5c 74 74 20 |k.a.~the| ``{\tt |
|00001220| 70 72 6f 67 6e 20 5c 73 | 69 6e 67 6c 65 71 75 6f |progn \s|inglequo|
|00001230| 74 65 20 63 6f 6d 70 69 | 6c 65 7d 20 68 61 63 6b |te compi|le} hack|
|00001240| 27 27 2e 29 7d 0a | |''.)}. | |
+--------+-------------------------+-------------------------+--------+--------+