home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / schmrprt / r399rs.lha / procs.tex < prev    next >
LaTeX Document  |  1989-08-31  |  106.9 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| 25 20 49 6e 69 74 69 61 | 6c 20 65 6e 76 69 72 6f |% Initia|l enviro|
|00000010| 6e 6d 65 6e 74 0a 0a 25 | 5c 76 66 69 6c 6c 5c 65 |nment..%|\vfill\e|
|00000020| 6a 65 63 74 0a 5c 63 68 | 61 70 74 65 72 7b 53 74 |ject.\ch|apter{St|
|00000030| 61 6e 64 61 72 64 20 70 | 72 6f 63 65 64 75 72 65 |andard p|rocedure|
|00000040| 73 7d 0a 5c 6c 61 62 65 | 6c 7b 69 6e 69 74 69 61 |s}.\labe|l{initia|
|00000050| 6c 65 6e 76 7d 0a 5c 6c | 61 62 65 6c 7b 62 75 69 |lenv}.\l|abel{bui|
|00000060| 6c 74 69 6e 63 68 61 70 | 74 65 72 7d 0a 0a 5c 6d |ltinchap|ter}..\m|
|00000070| 61 69 6e 69 6e 64 65 78 | 7b 69 6e 69 74 69 61 6c |ainindex|{initial|
|00000080| 20 65 6e 76 69 72 6f 6e | 6d 65 6e 74 7d 0a 5c 6d | environ|ment}.\m|
|00000090| 61 69 6e 69 6e 64 65 78 | 7b 74 6f 70 20 6c 65 76 |ainindex|{top lev|
|000000a0| 65 6c 20 65 6e 76 69 72 | 6f 6e 6d 65 6e 74 7d 0a |el envir|onment}.|
|000000b0| 0a 54 68 69 73 20 63 68 | 61 70 74 65 72 20 64 65 |.This ch|apter de|
|000000c0| 73 63 72 69 62 65 73 20 | 53 63 68 65 6d 65 27 73 |scribes |Scheme's|
|000000d0| 20 62 75 69 6c 74 2d 69 | 6e 20 70 72 6f 63 65 64 | built-i|n proced|
|000000e0| 75 72 65 73 2e 20 20 54 | 68 65 20 69 6e 69 74 69 |ures. T|he initi|
|000000f0| 61 6c 20 28 6f 72 0a 60 | 60 74 6f 70 20 6c 65 76 |al (or.`|`top lev|
|00000100| 65 6c 27 27 29 20 53 63 | 68 65 6d 65 20 65 6e 76 |el'') Sc|heme env|
|00000110| 69 72 6f 6e 6d 65 6e 74 | 20 73 74 61 72 74 73 20 |ironment| starts |
|00000120| 6f 75 74 20 77 69 74 68 | 20 61 20 6e 75 6d 62 65 |out with| a numbe|
|00000130| 72 20 6f 66 20 76 61 72 | 69 61 62 6c 65 73 0a 62 |r of var|iables.b|
|00000140| 6f 75 6e 64 20 74 6f 20 | 6c 6f 63 61 74 69 6f 6e |ound to |location|
|00000150| 73 20 63 6f 6e 74 61 69 | 6e 69 6e 67 20 75 73 65 |s contai|ning use|
|00000160| 66 75 6c 20 76 61 6c 75 | 65 73 2c 20 6d 6f 73 74 |ful valu|es, most|
|00000170| 20 6f 66 20 77 68 69 63 | 68 20 61 72 65 20 70 72 | of whic|h are pr|
|00000180| 69 6d 69 74 69 76 65 0a | 70 72 6f 63 65 64 75 72 |imitive.|procedur|
|00000190| 65 73 20 74 68 61 74 20 | 6d 61 6e 69 70 75 6c 61 |es that |manipula|
|000001a0| 74 65 20 64 61 74 61 2e | 20 20 46 6f 72 20 65 78 |te data.| For ex|
|000001b0| 61 6d 70 6c 65 2c 20 74 | 68 65 20 76 61 72 69 61 |ample, t|he varia|
|000001c0| 62 6c 65 20 5c 69 64 65 | 7b 61 62 73 7d 20 69 73 |ble \ide|{abs} is|
|000001d0| 0a 62 6f 75 6e 64 20 74 | 6f 20 28 61 20 6c 6f 63 |.bound t|o (a loc|
|000001e0| 61 74 69 6f 6e 20 69 6e | 69 74 69 61 6c 6c 79 20 |ation in|itially |
|000001f0| 63 6f 6e 74 61 69 6e 69 | 6e 67 29 20 61 20 70 72 |containi|ng) a pr|
|00000200| 6f 63 65 64 75 72 65 20 | 6f 66 20 6f 6e 65 20 61 |ocedure |of one a|
|00000210| 72 67 75 6d 65 6e 74 0a | 74 68 61 74 20 63 6f 6d |rgument.|that com|
|00000220| 70 75 74 65 73 20 74 68 | 65 20 61 62 73 6f 6c 75 |putes th|e absolu|
|00000230| 74 65 20 76 61 6c 75 65 | 20 6f 66 20 61 20 6e 75 |te value| of a nu|
|00000240| 6d 62 65 72 2c 20 61 6e | 64 20 74 68 65 20 76 61 |mber, an|d the va|
|00000250| 72 69 61 62 6c 65 20 5c | 69 64 65 7b 2b 7d 0a 69 |riable \|ide{+}.i|
|00000260| 73 20 62 6f 75 6e 64 20 | 74 6f 20 61 20 70 72 6f |s bound |to a pro|
|00000270| 63 65 64 75 72 65 20 74 | 68 61 74 20 63 6f 6d 70 |cedure t|hat comp|
|00000280| 75 74 65 73 20 73 75 6d | 73 2e 0a 0a 0a 5c 73 65 |utes sum|s....\se|
|00000290| 63 74 69 6f 6e 7b 42 6f | 6f 6c 65 61 6e 73 7d 0a |ction{Bo|oleans}.|
|000002a0| 5c 6c 61 62 65 6c 7b 62 | 6f 6f 6c 65 61 6e 73 65 |\label{b|ooleanse|
|000002b0| 63 74 69 6f 6e 7d 0a 0a | 54 68 65 20 73 74 61 6e |ction}..|The stan|
|000002c0| 64 61 72 64 20 62 6f 6f | 6c 65 61 6e 20 6f 62 6a |dard boo|lean obj|
|000002d0| 65 63 74 73 20 66 6f 72 | 20 74 72 75 65 20 61 6e |ects for| true an|
|000002e0| 64 20 66 61 6c 73 65 20 | 61 72 65 20 77 72 69 74 |d false |are writ|
|000002f0| 74 65 6e 20 61 73 0a 5c | 73 63 68 74 72 75 65 7b |ten as.\|schtrue{|
|00000300| 7d 20 61 6e 64 20 5c 73 | 63 68 66 61 6c 73 65 2e |} and \s|chfalse.|
|00000310| 5c 73 68 61 72 70 69 6e | 64 65 78 7b 74 7d 5c 73 |\sharpin|dex{t}\s|
|00000320| 68 61 72 70 69 6e 64 65 | 78 7b 66 7d 20 20 57 68 |harpinde|x{f} Wh|
|00000330| 61 74 20 72 65 61 6c 6c | 79 0a 6d 61 74 74 65 72 |at reall|y.matter|
|00000340| 73 2c 20 74 68 6f 75 67 | 68 2c 20 61 72 65 20 74 |s, thoug|h, are t|
|00000350| 68 65 20 6f 62 6a 65 63 | 74 73 20 74 68 61 74 20 |he objec|ts that |
|00000360| 74 68 65 20 53 63 68 65 | 6d 65 20 63 6f 6e 64 69 |the Sche|me condi|
|00000370| 74 69 6f 6e 61 6c 20 65 | 78 70 72 65 73 73 69 6f |tional e|xpressio|
|00000380| 6e 73 0a 28 5c 69 64 65 | 7b 69 66 7d 2c 20 5c 69 |ns.(\ide|{if}, \i|
|00000390| 64 65 7b 63 6f 6e 64 7d | 2c 20 5c 69 64 65 7b 61 |de{cond}|, \ide{a|
|000003a0| 6e 64 7d 2c 20 5c 69 64 | 65 7b 6f 72 7d 2c 20 5c |nd}, \id|e{or}, \|
|000003b0| 69 64 65 7b 64 6f 7d 29 | 20 74 72 65 61 74 20 61 |ide{do})| treat a|
|000003c0| 73 0a 74 72 75 65 5c 69 | 6e 64 65 78 7b 74 72 75 |s.true\i|ndex{tru|
|000003d0| 65 7d 20 6f 72 20 66 61 | 6c 73 65 5c 69 6e 64 65 |e} or fa|lse\inde|
|000003e0| 78 7b 66 61 6c 73 65 7d | 2e 20 20 54 68 65 20 70 |x{false}|. The p|
|000003f0| 68 72 61 73 65 20 60 60 | 61 20 74 72 75 65 20 76 |hrase ``|a true v|
|00000400| 61 6c 75 65 27 27 5c 69 | 6e 64 65 78 7b 74 72 75 |alue''\i|ndex{tru|
|00000410| 65 7d 0a 28 6f 72 20 73 | 6f 6d 65 74 69 6d 65 73 |e}.(or s|ometimes|
|00000420| 20 6a 75 73 74 20 60 60 | 74 72 75 65 27 27 29 20 | just ``|true'') |
|00000430| 6d 65 61 6e 73 20 61 6e | 79 20 6f 62 6a 65 63 74 |means an|y object|
|00000440| 20 74 72 65 61 74 65 64 | 20 61 73 20 74 72 75 65 | treated| as true|
|00000450| 20 62 79 20 74 68 65 0a | 63 6f 6e 64 69 74 69 6f | by the.|conditio|
|00000460| 6e 61 6c 20 65 78 70 72 | 65 73 73 69 6f 6e 73 2c |nal expr|essions,|
|00000470| 20 61 6e 64 20 74 68 65 | 20 70 68 72 61 73 65 20 | and the| phrase |
|00000480| 60 60 61 20 66 61 6c 73 | 65 20 76 61 6c 75 65 27 |``a fals|e value'|
|00000490| 27 5c 69 6e 64 65 78 7b | 66 61 6c 73 65 7d 20 28 |'\index{|false} (|
|000004a0| 6f 72 0a 60 60 66 61 6c | 73 65 27 27 29 20 6d 65 |or.``fal|se'') me|
|000004b0| 61 6e 73 20 61 6e 79 20 | 6f 62 6a 65 63 74 20 74 |ans any |object t|
|000004c0| 72 65 61 74 65 64 20 61 | 73 20 66 61 6c 73 65 20 |reated a|s false |
|000004d0| 62 79 20 74 68 65 20 63 | 6f 6e 64 69 74 69 6f 6e |by the c|ondition|
|000004e0| 61 6c 20 65 78 70 72 65 | 73 73 69 6f 6e 73 2e 0a |al expre|ssions..|
|000004f0| 0a 5c 76 65 73 74 20 4f | 66 20 61 6c 6c 20 74 68 |.\vest O|f all th|
|00000500| 65 20 73 74 61 6e 64 61 | 72 64 20 53 63 68 65 6d |e standa|rd Schem|
|00000510| 65 20 76 61 6c 75 65 73 | 2c 20 6f 6e 6c 79 20 5c |e values|, only \|
|00000520| 73 63 68 66 61 6c 73 65 | 7b 7d 20 69 73 0a 67 75 |schfalse|{} is.gu|
|00000530| 61 72 61 6e 74 65 65 64 | 20 74 6f 20 63 6f 75 6e |aranteed| to coun|
|00000540| 74 20 61 73 20 66 61 6c | 73 65 20 69 6e 20 63 6f |t as fal|se in co|
|00000550| 6e 64 69 74 69 6f 6e 61 | 6c 20 65 78 70 72 65 73 |nditiona|l expres|
|00000560| 73 69 6f 6e 73 2e 20 20 | 49 74 20 69 73 20 6e 6f |sions. |It is no|
|00000570| 74 0a 73 70 65 63 69 66 | 69 65 64 20 77 68 65 74 |t.specif|ied whet|
|00000580| 68 65 72 20 74 68 65 20 | 65 6d 70 74 79 20 6c 69 |her the |empty li|
|00000590| 73 74 5c 69 6e 64 65 78 | 7b 65 6d 70 74 79 20 6c |st\index|{empty l|
|000005a0| 69 73 74 7d 20 63 6f 75 | 6e 74 73 20 61 73 20 66 |ist} cou|nts as f|
|000005b0| 61 6c 73 65 0a 6f 72 20 | 61 73 20 74 72 75 65 20 |alse.or |as true |
|000005c0| 69 6e 20 63 6f 6e 64 69 | 74 69 6f 6e 61 6c 20 65 |in condi|tional e|
|000005d0| 78 70 72 65 73 73 69 6f | 6e 73 2e 20 20 45 78 63 |xpressio|ns. Exc|
|000005e0| 65 70 74 20 66 6f 72 20 | 5c 73 63 68 66 61 6c 73 |ept for |\schfals|
|000005f0| 65 7b 7d 0a 61 6e 64 20 | 70 6f 73 73 69 62 6c 79 |e{}.and |possibly|
|00000600| 20 74 68 65 20 65 6d 70 | 74 79 20 6c 69 73 74 2c | the emp|ty list,|
|00000610| 20 61 6c 6c 20 73 74 61 | 6e 64 61 72 64 20 53 63 | all sta|ndard Sc|
|00000620| 68 65 6d 65 20 76 61 6c | 75 65 73 2c 20 69 6e 63 |heme val|ues, inc|
|00000630| 6c 75 64 69 6e 67 20 5c | 73 63 68 74 72 75 65 2c |luding \|schtrue,|
|00000640| 0a 70 61 69 72 73 2c 20 | 73 79 6d 62 6f 6c 73 2c |.pairs, |symbols,|
|00000650| 20 6e 75 6d 62 65 72 73 | 2c 20 73 74 72 69 6e 67 | numbers|, string|
|00000660| 73 2c 20 76 65 63 74 6f | 72 73 2c 20 61 6e 64 20 |s, vecto|rs, and |
|00000670| 70 72 6f 63 65 64 75 72 | 65 73 2c 20 63 6f 75 6e |procedur|es, coun|
|00000680| 74 20 61 73 20 74 72 75 | 65 2e 0a 0a 5c 62 65 67 |t as tru|e...\beg|
|00000690| 69 6e 7b 72 61 74 69 6f | 6e 61 6c 65 7d 0a 46 6f |in{ratio|nale}.Fo|
|000006a0| 72 20 68 69 73 74 6f 72 | 69 63 61 6c 20 72 65 61 |r histor|ical rea|
|000006b0| 73 6f 6e 73 20 73 6f 6d | 65 20 69 6d 70 6c 65 6d |sons som|e implem|
|000006c0| 65 6e 74 61 74 69 6f 6e | 73 20 72 65 67 61 72 64 |entation|s regard|
|000006d0| 20 5c 73 63 68 66 61 6c | 73 65 7b 7d 20 61 6e 64 | \schfal|se{} and|
|000006e0| 20 74 68 65 0a 65 6d 70 | 74 79 20 6c 69 73 74 20 | the.emp|ty list |
|000006f0| 61 73 20 74 68 65 20 73 | 61 6d 65 20 6f 62 6a 65 |as the s|ame obje|
|00000700| 63 74 2e 20 20 54 68 65 | 73 65 20 69 6d 70 6c 65 |ct. The|se imple|
|00000710| 6d 65 6e 74 61 74 69 6f | 6e 73 20 74 68 65 72 65 |mentatio|ns there|
|00000720| 66 6f 72 65 20 63 61 6e | 6e 6f 74 0a 6d 61 6b 65 |fore can|not.make|
|00000730| 20 74 68 65 20 65 6d 70 | 74 79 20 6c 69 73 74 20 | the emp|ty list |
|00000740| 63 6f 75 6e 74 20 61 73 | 20 74 72 75 65 20 69 6e |count as| true in|
|00000750| 20 63 6f 6e 64 69 74 69 | 6f 6e 61 6c 20 65 78 70 | conditi|onal exp|
|00000760| 72 65 73 73 69 6f 6e 73 | 2e 0a 5c 65 6e 64 7b 72 |ressions|..\end{r|
|00000770| 61 74 69 6f 6e 61 6c 65 | 7d 0a 0a 5c 62 65 67 69 |ationale|}..\begi|
|00000780| 6e 7b 6e 6f 74 65 7d 0a | 50 72 6f 67 72 61 6d 6d |n{note}.|Programm|
|00000790| 65 72 73 20 61 63 63 75 | 73 74 6f 6d 65 64 20 74 |ers accu|stomed t|
|000007a0| 6f 20 6f 74 68 65 72 20 | 64 69 61 6c 65 63 74 73 |o other |dialects|
|000007b0| 20 6f 66 20 4c 69 73 70 | 20 73 68 6f 75 6c 64 20 | of Lisp| should |
|000007c0| 62 65 20 61 77 61 72 65 | 20 74 68 61 74 0a 53 63 |be aware| that.Sc|
|000007d0| 68 65 6d 65 20 64 69 73 | 74 69 6e 67 75 69 73 68 |heme dis|tinguish|
|000007e0| 65 73 20 62 6f 74 68 20 | 5c 73 63 68 66 61 6c 73 |es both |\schfals|
|000007f0| 65 7b 7d 20 61 6e 64 20 | 74 68 65 20 65 6d 70 74 |e{} and |the empt|
|00000800| 79 20 6c 69 73 74 20 66 | 72 6f 6d 20 74 68 65 20 |y list f|rom the |
|00000810| 73 79 6d 62 6f 6c 0a 5c | 69 64 65 7b 6e 69 6c 7d |symbol.\|ide{nil}|
|00000820| 2e 0a 5c 65 6e 64 7b 6e | 6f 74 65 7d 0a 0a 5c 76 |..\end{n|ote}..\v|
|00000830| 65 73 74 20 42 6f 6f 6c | 65 61 6e 20 63 6f 6e 73 |est Bool|ean cons|
|00000840| 74 61 6e 74 73 20 65 76 | 61 6c 75 61 74 65 20 74 |tants ev|aluate t|
|00000850| 6f 20 74 68 65 6d 73 65 | 6c 76 65 73 2c 20 73 6f |o themse|lves, so|
|00000860| 20 74 68 65 79 20 64 6f | 6e 27 74 20 6e 65 65 64 | they do|n't need|
|00000870| 20 74 6f 20 62 65 20 71 | 75 6f 74 65 64 0a 69 6e | to be q|uoted.in|
|00000880| 20 70 72 6f 67 72 61 6d | 73 2e 0a 0a 5c 62 65 67 | program|s...\beg|
|00000890| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 5c 73 63 68 74 |in{schem|e}.\scht|
|000008a0| 72 75 65 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 |rue | \ev |
|000008b0| 20 5c 73 63 68 74 72 75 | 65 0a 5c 73 63 68 66 61 | \schtru|e.\schfa|
|000008c0| 6c 73 65 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 |lse | \ev |
|000008d0| 5c 73 63 68 66 61 6c 73 | 65 0a 27 5c 73 63 68 66 |\schfals|e.'\schf|
|000008e0| 61 6c 73 65 20 20 20 20 | 20 20 20 5c 65 76 20 20 |alse | \ev |
|000008f0| 5c 73 63 68 66 61 6c 73 | 65 25 0a 5c 65 6e 64 7b |\schfals|e%.\end{|
|00000900| 73 63 68 65 6d 65 7d 0a | 0a 0a 5c 62 65 67 69 6e |scheme}.|..\begin|
|00000910| 7b 65 6e 74 72 79 7d 7b | 25 0a 5c 70 72 6f 74 6f |{entry}{|%.\proto|
|00000920| 7b 6e 6f 74 7d 7b 20 6f | 62 6a 7d 7b 65 73 73 65 |{not}{ o|bj}{esse|
|00000930| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00000940| 7d 0a 0a 5c 69 64 65 7b | 4e 6f 74 7d 20 72 65 74 |}..\ide{|Not} ret|
|00000950| 75 72 6e 73 20 5c 73 63 | 68 74 72 75 65 7b 7d 20 |urns \sc|htrue{} |
|00000960| 69 66 20 5c 76 61 72 7b | 6f 62 6a 7d 20 69 73 20 |if \var{|obj} is |
|00000970| 66 61 6c 73 65 2c 20 61 | 6e 64 20 72 65 74 75 72 |false, a|nd retur|
|00000980| 6e 73 0a 5c 73 63 68 66 | 61 6c 73 65 7b 7d 20 6f |ns.\schf|alse{} o|
|00000990| 74 68 65 72 77 69 73 65 | 2e 0a 0a 5c 62 65 67 69 |therwise|...\begi|
|000009a0| 6e 7b 73 63 68 65 6d 65 | 7d 0a 28 6e 6f 74 20 5c |n{scheme|}.(not \|
|000009b0| 73 63 68 74 72 75 65 29 | 20 20 20 5c 65 76 20 20 |schtrue)| \ev |
|000009c0| 5c 73 63 68 66 61 6c 73 | 65 0a 28 6e 6f 74 20 33 |\schfals|e.(not 3|
|000009d0| 29 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 |) | \ev |
|000009e0| 5c 73 63 68 66 61 6c 73 | 65 0a 28 6e 6f 74 20 28 |\schfals|e.(not (|
|000009f0| 6c 69 73 74 20 33 29 29 | 20 20 20 5c 65 76 20 20 |list 3))| \ev |
|00000a00| 5c 73 63 68 66 61 6c 73 | 65 0a 28 6e 6f 74 20 5c |\schfals|e.(not \|
|00000a10| 73 63 68 66 61 6c 73 65 | 29 20 20 5c 65 76 20 20 |schfalse|) \ev |
|00000a20| 5c 73 63 68 74 72 75 65 | 0a 28 6e 6f 74 20 27 28 |\schtrue|.(not '(|
|00000a30| 29 29 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c |)) | \ev \|
|00000a40| 75 6e 73 70 65 63 69 66 | 69 65 64 0a 28 6e 6f 74 |unspecif|ied.(not|
|00000a50| 20 28 6c 69 73 74 29 29 | 20 20 20 20 20 5c 65 76 | (list))| \ev|
|00000a60| 20 20 5c 75 6e 73 70 65 | 63 69 66 69 65 64 0a 28 | \unspe|cified.(|
|00000a70| 6e 6f 74 20 27 6e 69 6c | 29 20 20 20 20 20 20 20 |not 'nil|) |
|00000a80| 5c 65 76 20 20 5c 73 63 | 68 66 61 6c 73 65 25 0a |\ev \sc|hfalse%.|
|00000a90| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 5c 65 |\end{sch|eme}..\e|
|00000aa0| 6e 64 7b 65 6e 74 72 79 | 7d 0a 0a 0a 5c 62 65 67 |nd{entry|}...\beg|
|00000ab0| 69 6e 7b 65 6e 74 72 79 | 7d 7b 25 0a 5c 70 72 6f |in{entry|}{%.\pro|
|00000ac0| 74 6f 7b 62 6f 6f 6c 65 | 61 6e 3f 7d 7b 20 6f 62 |to{boole|an?}{ ob|
|00000ad0| 6a 7d 7b 65 73 73 65 6e | 74 69 61 6c 20 70 72 6f |j}{essen|tial pro|
|00000ae0| 63 65 64 75 72 65 7d 7d | 0a 0a 5c 69 64 65 7b 42 |cedure}}|..\ide{B|
|00000af0| 6f 6f 6c 65 61 6e 3f 7d | 20 72 65 74 75 72 6e 73 |oolean?}| returns|
|00000b00| 20 5c 73 63 68 74 72 75 | 65 7b 7d 20 69 66 20 5c | \schtru|e{} if \|
|00000b10| 76 61 72 7b 6f 62 6a 7d | 20 69 73 20 65 69 74 68 |var{obj}| is eith|
|00000b20| 65 72 20 5c 73 63 68 74 | 72 75 65 7b 7d 20 6f 72 |er \scht|rue{} or|
|00000b30| 0a 5c 73 63 68 66 61 6c | 73 65 7b 7d 20 61 6e 64 |.\schfal|se{} and|
|00000b40| 20 72 65 74 75 72 6e 73 | 20 5c 73 63 68 66 61 6c | returns| \schfal|
|00000b50| 73 65 7b 7d 20 6f 74 68 | 65 72 77 69 73 65 2e 0a |se{} oth|erwise..|
|00000b60| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00000b70| 28 62 6f 6f 6c 65 61 6e | 3f 20 5c 73 63 68 66 61 |(boolean|? \schfa|
|00000b80| 6c 73 65 29 20 20 5c 65 | 76 20 20 5c 73 63 68 74 |lse) \e|v \scht|
|00000b90| 72 75 65 0a 28 62 6f 6f | 6c 65 61 6e 3f 20 30 29 |rue.(boo|lean? 0)|
|00000ba0| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c | | \ev \|
|00000bb0| 73 63 68 66 61 6c 73 65 | 0a 28 62 6f 6f 6c 65 61 |schfalse|.(boolea|
|00000bc0| 6e 3f 20 27 28 29 29 20 | 20 20 20 20 20 20 20 5c |n? '()) | \|
|00000bd0| 65 76 20 20 5c 75 6e 73 | 70 65 63 69 66 69 65 64 |ev \uns|pecified|
|00000be0| 25 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 0a |%.\end{s|cheme}..|
|00000bf0| 5c 65 6e 64 7b 65 6e 74 | 72 79 7d 0a 0a 20 0a 5c |\end{ent|ry}.. .\|
|00000c00| 73 65 63 74 69 6f 6e 7b | 45 71 75 69 76 61 6c 65 |section{|Equivale|
|00000c10| 6e 63 65 20 70 72 65 64 | 69 63 61 74 65 73 7d 0a |nce pred|icates}.|
|00000c20| 5c 6c 61 62 65 6c 7b 65 | 71 75 69 76 61 6c 65 6e |\label{e|quivalen|
|00000c30| 63 65 73 65 63 74 69 6f | 6e 7d 0a 0a 41 20 5c 64 |cesectio|n}..A \d|
|00000c40| 65 66 69 6e 69 6e 67 7b | 70 72 65 64 69 63 61 74 |efining{|predicat|
|00000c50| 65 7d 20 69 73 20 61 20 | 70 72 6f 63 65 64 75 72 |e} is a |procedur|
|00000c60| 65 20 74 68 61 74 20 61 | 6c 77 61 79 73 20 72 65 |e that a|lways re|
|00000c70| 74 75 72 6e 73 20 61 20 | 62 6f 6f 6c 65 61 6e 0a |turns a |boolean.|
|00000c80| 76 61 6c 75 65 20 28 5c | 73 63 68 74 72 75 65 7b |value (\|schtrue{|
|00000c90| 7d 20 6f 72 20 5c 73 63 | 68 66 61 6c 73 65 29 2e |} or \sc|hfalse).|
|00000ca0| 20 20 41 6e 20 5c 64 65 | 66 69 6e 69 6e 67 7b 65 | An \de|fining{e|
|00000cb0| 71 75 69 76 61 6c 65 6e | 63 65 20 70 72 65 64 69 |quivalen|ce predi|
|00000cc0| 63 61 74 65 7d 20 69 73 | 0a 74 68 65 20 63 6f 6d |cate} is|.the com|
|00000cd0| 70 75 74 61 74 69 6f 6e | 61 6c 20 61 6e 61 6c 6f |putation|al analo|
|00000ce0| 67 75 65 20 6f 66 20 61 | 20 6d 61 74 68 65 6d 61 |gue of a| mathema|
|00000cf0| 74 69 63 61 6c 20 65 71 | 75 69 76 61 6c 65 6e 63 |tical eq|uivalenc|
|00000d00| 65 20 72 65 6c 61 74 69 | 6f 6e 20 28 69 74 20 69 |e relati|on (it i|
|00000d10| 73 0a 73 79 6d 6d 65 74 | 72 69 63 2c 20 72 65 66 |s.symmet|ric, ref|
|00000d20| 6c 65 78 69 76 65 2c 20 | 61 6e 64 20 74 72 61 6e |lexive, |and tran|
|00000d30| 73 69 74 69 76 65 29 2e | 20 20 4f 66 20 74 68 65 |sitive).| Of the|
|00000d40| 20 65 71 75 69 76 61 6c | 65 6e 63 65 20 70 72 65 | equival|ence pre|
|00000d50| 64 69 63 61 74 65 73 0a | 64 65 73 63 72 69 62 65 |dicates.|describe|
|00000d60| 64 20 69 6e 20 74 68 69 | 73 20 73 65 63 74 69 6f |d in thi|s sectio|
|00000d70| 6e 2c 20 5c 69 64 65 7b | 65 71 3f 7d 5c 20 69 73 |n, \ide{|eq?}\ is|
|00000d80| 20 74 68 65 20 66 69 6e | 65 73 74 20 6f 72 20 6d | the fin|est or m|
|00000d90| 6f 73 74 0a 64 69 73 63 | 72 69 6d 69 6e 61 74 69 |ost.disc|riminati|
|00000da0| 6e 67 2c 20 61 6e 64 20 | 5c 69 64 65 7b 65 71 75 |ng, and |\ide{equ|
|00000db0| 61 6c 3f 7d 5c 20 69 73 | 20 74 68 65 20 63 6f 61 |al?}\ is| the coa|
|00000dc0| 72 73 65 73 74 2e 20 20 | 5c 69 64 65 7b 45 71 76 |rsest. |\ide{Eqv|
|00000dd0| 3f 7d 5c 20 69 73 0a 73 | 6c 69 67 68 74 6c 79 20 |?}\ is.s|lightly |
|00000de0| 6c 65 73 73 20 64 69 73 | 63 72 69 6d 69 6e 61 74 |less dis|criminat|
|00000df0| 69 6e 67 20 74 68 61 6e | 20 5c 69 64 65 7b 65 71 |ing than| \ide{eq|
|00000e00| 3f 7d 2e 20 20 5c 74 6f | 64 6f 7b 50 69 74 6d 61 |?}. \to|do{Pitma|
|00000e10| 6e 20 64 6f 65 73 6e 27 | 74 20 6c 69 6b 65 0a 74 |n doesn'|t like.t|
|00000e20| 68 69 73 20 70 61 72 61 | 67 72 61 70 68 2e 20 20 |his para|graph. |
|00000e30| 4c 69 66 74 20 74 68 65 | 20 64 69 73 63 75 73 73 |Lift the| discuss|
|00000e40| 69 6f 6e 20 66 72 6f 6d | 20 74 68 65 20 4d 61 63 |ion from| the Mac|
|00000e50| 6c 69 73 70 20 6d 61 6e | 75 61 6c 2e 20 20 45 78 |lisp man|ual. Ex|
|00000e60| 70 6c 61 69 6e 0a 77 68 | 79 20 74 68 65 72 65 27 |plain.wh|y there'|
|00000e70| 73 20 6d 6f 72 65 20 74 | 68 61 6e 20 6f 6e 65 20 |s more t|han one |
|00000e80| 70 72 65 64 69 63 61 74 | 65 2e 7d 0a 0a 0a 5c 62 |predicat|e.}...\b|
|00000e90| 65 67 69 6e 7b 65 6e 74 | 72 79 7d 7b 25 0a 5c 70 |egin{ent|ry}{%.\p|
|00000ea0| 72 6f 74 6f 7b 65 71 76 | 3f 7d 7b 20 5c 76 61 72 |roto{eqv|?}{ \var|
|00000eb0| 69 7b 6f 62 6a 7d 20 5c | 76 61 72 69 69 7b 6f 62 |i{obj} \|varii{ob|
|00000ec0| 6a 7d 7d 7b 65 73 73 65 | 6e 74 69 61 6c 20 70 72 |j}}{esse|ntial pr|
|00000ed0| 6f 63 65 64 75 72 65 7d | 7d 0a 0a 54 68 65 20 5c |ocedure}|}..The \|
|00000ee0| 69 64 65 7b 65 71 76 3f | 7d 20 70 72 6f 63 65 64 |ide{eqv?|} proced|
|00000ef0| 75 72 65 20 64 65 66 69 | 6e 65 73 20 61 20 75 73 |ure defi|nes a us|
|00000f00| 65 66 75 6c 20 65 71 75 | 69 76 61 6c 65 6e 63 65 |eful equ|ivalence|
|00000f10| 20 72 65 6c 61 74 69 6f | 6e 20 6f 6e 20 6f 62 6a | relatio|n on obj|
|00000f20| 65 63 74 73 2e 0a 42 72 | 69 65 66 6c 79 2c 20 69 |ects..Br|iefly, i|
|00000f30| 74 20 72 65 74 75 72 6e | 73 20 5c 73 63 68 74 72 |t return|s \schtr|
|00000f40| 75 65 7b 7d 20 69 66 20 | 5c 76 61 72 69 7b 6f 62 |ue{} if |\vari{ob|
|00000f50| 6a 7d 20 61 6e 64 20 5c | 76 61 72 69 69 7b 6f 62 |j} and \|varii{ob|
|00000f60| 6a 7d 20 73 68 6f 75 6c | 64 0a 6e 6f 72 6d 61 6c |j} shoul|d.normal|
|00000f70| 6c 79 20 62 65 20 72 65 | 67 61 72 64 65 64 20 61 |ly be re|garded a|
|00000f80| 73 20 74 68 65 20 73 61 | 6d 65 20 6f 62 6a 65 63 |s the sa|me objec|
|00000f90| 74 2e 20 20 54 68 69 73 | 20 72 65 6c 61 74 69 6f |t. This| relatio|
|00000fa0| 6e 20 69 73 20 6c 65 66 | 74 20 73 6c 69 67 68 74 |n is lef|t slight|
|00000fb0| 6c 79 0a 6f 70 65 6e 20 | 74 6f 20 69 6e 74 65 72 |ly.open |to inter|
|00000fc0| 70 72 65 74 61 74 69 6f | 6e 2c 20 62 75 74 20 74 |pretatio|n, but t|
|00000fd0| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 70 61 72 |he follo|wing par|
|00000fe0| 74 69 61 6c 20 73 70 65 | 63 69 66 69 63 61 74 69 |tial spe|cificati|
|00000ff0| 6f 6e 20 6f 66 0a 5c 69 | 64 65 7b 65 71 76 3f 7d |on of.\i|de{eqv?}|
|00001000| 20 68 6f 6c 64 73 20 66 | 6f 72 20 61 6c 6c 20 69 | holds f|or all i|
|00001010| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 73 20 6f |mplement|ations o|
|00001020| 66 20 53 63 68 65 6d 65 | 2e 0a 0a 54 68 65 20 5c |f Scheme|...The \|
|00001030| 69 64 65 7b 65 71 76 3f | 7d 20 70 72 6f 63 65 64 |ide{eqv?|} proced|
|00001040| 75 72 65 20 72 65 74 75 | 72 6e 73 20 5c 73 63 68 |ure retu|rns \sch|
|00001050| 74 72 75 65 7b 7d 20 69 | 66 3a 0a 0a 5c 62 65 67 |true{} i|f:..\beg|
|00001060| 69 6e 7b 69 74 65 6d 69 | 7a 65 7d 0a 5c 69 74 65 |in{itemi|ze}.\ite|
|00001070| 6d 20 5c 76 61 72 69 7b | 6f 62 6a 7d 20 61 6e 64 |m \vari{|obj} and|
|00001080| 20 5c 76 61 72 69 69 7b | 6f 62 6a 7d 20 61 72 65 | \varii{|obj} are|
|00001090| 20 62 6f 74 68 20 5c 73 | 63 68 74 72 75 65 7b 7d | both \s|chtrue{}|
|000010a0| 20 6f 72 20 62 6f 74 68 | 20 5c 73 63 68 66 61 6c | or both| \schfal|
|000010b0| 73 65 2e 0a 0a 5c 69 74 | 65 6d 20 5c 76 61 72 69 |se...\it|em \vari|
|000010c0| 7b 6f 62 6a 7d 20 61 6e | 64 20 5c 76 61 72 69 69 |{obj} an|d \varii|
|000010d0| 7b 6f 62 6a 7d 20 61 72 | 65 20 62 6f 74 68 20 73 |{obj} ar|e both s|
|000010e0| 79 6d 62 6f 6c 73 20 61 | 6e 64 0a 0a 5c 62 65 67 |ymbols a|nd..\beg|
|000010f0| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 73 74 72 69 |in{schem|e}.(stri|
|00001100| 6e 67 3d 3f 20 28 73 79 | 6d 62 6f 6c 2d 3e 73 74 |ng=? (sy|mbol->st|
|00001110| 72 69 6e 67 20 6f 62 6a | 31 29 0a 20 20 20 20 20 |ring obj|1). |
|00001120| 20 20 20 20 20 28 73 79 | 6d 62 6f 6c 2d 3e 73 74 | (sy|mbol->st|
|00001130| 72 69 6e 67 20 6f 62 6a | 32 29 29 0a 20 20 20 20 |ring obj|2)). |
|00001140| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 25 0a 5c |\ev \sc|htrue%.\|
|00001150| 65 6e 64 7b 73 63 68 65 | 6d 65 7d 0a 0a 5c 62 65 |end{sche|me}..\be|
|00001160| 67 69 6e 7b 6e 6f 74 65 | 7d 20 0a 54 68 69 73 20 |gin{note|} .This |
|00001170| 61 73 73 75 6d 65 73 20 | 74 68 61 74 20 6e 65 69 |assumes |that nei|
|00001180| 74 68 65 72 20 5c 76 61 | 72 69 7b 6f 62 6a 7d 20 |ther \va|ri{obj} |
|00001190| 6e 6f 72 20 5c 76 61 72 | 69 69 7b 6f 62 6a 7d 20 |nor \var|ii{obj} |
|000011a0| 69 73 20 61 6e 20 60 60 | 75 6e 69 6e 74 65 72 6e |is an ``|unintern|
|000011b0| 65 64 0a 73 79 6d 62 6f | 6c 27 27 20 61 73 20 61 |ed.symbo|l'' as a|
|000011c0| 6c 6c 75 64 65 64 20 74 | 6f 20 69 6e 20 73 65 63 |lluded t|o in sec|
|000011d0| 74 69 6f 6e 7e 5c 72 65 | 66 7b 73 79 6d 62 6f 6c |tion~\re|f{symbol|
|000011e0| 73 65 63 74 69 6f 6e 7d | 2e 20 20 54 68 69 73 20 |section}|. This |
|000011f0| 72 65 70 6f 72 74 20 64 | 6f 65 73 0a 6e 6f 74 20 |report d|oes.not |
|00001200| 70 72 65 73 75 6d 65 20 | 74 6f 20 73 70 65 63 69 |presume |to speci|
|00001210| 66 79 20 74 68 65 20 62 | 65 68 61 76 69 6f 72 20 |fy the b|ehavior |
|00001220| 6f 66 20 5c 69 64 65 7b | 65 71 76 3f 7d 20 6f 6e |of \ide{|eqv?} on|
|00001230| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 2d | impleme|ntation-|
|00001240| 64 65 70 65 6e 64 65 6e | 74 0a 65 78 74 65 6e 73 |dependen|t.extens|
|00001250| 69 6f 6e 73 2e 0a 5c 65 | 6e 64 7b 6e 6f 74 65 7d |ions..\e|nd{note}|
|00001260| 0a 0a 5c 69 74 65 6d 20 | 5c 76 61 72 69 7b 6f 62 |..\item |\vari{ob|
|00001270| 6a 7d 20 61 6e 64 20 5c | 76 61 72 69 69 7b 6f 62 |j} and \|varii{ob|
|00001280| 6a 7d 20 61 72 65 20 62 | 6f 74 68 20 6e 75 6d 62 |j} are b|oth numb|
|00001290| 65 72 73 2c 20 61 72 65 | 20 6e 75 6d 65 72 69 63 |ers, are| numeric|
|000012a0| 61 6c 6c 79 0a 65 71 75 | 61 6c 20 28 73 65 65 20 |ally.equ|al (see |
|000012b0| 5c 69 64 65 7b 3d 7d 2c | 20 73 65 63 74 69 6f 6e |\ide{=},| section|
|000012c0| 7e 5c 72 65 66 7b 6e 75 | 6d 62 65 72 73 65 63 74 |~\ref{nu|mbersect|
|000012d0| 69 6f 6e 7d 29 2c 20 61 | 6e 64 20 61 72 65 20 65 |ion}), a|nd are e|
|000012e0| 69 74 68 65 72 20 62 6f | 74 68 0a 65 78 61 63 74 |ither bo|th.exact|
|000012f0| 5c 69 6e 64 65 78 7b 65 | 78 61 63 74 7d 20 6f 72 |\index{e|xact} or|
|00001300| 20 62 6f 74 68 20 69 6e | 65 78 61 63 74 5c 69 6e | both in|exact\in|
|00001310| 64 65 78 7b 69 6e 65 78 | 61 63 74 7d 2e 0a 0a 5c |dex{inex|act}...\|
|00001320| 69 74 65 6d 20 5c 76 61 | 72 69 7b 6f 62 6a 7d 20 |item \va|ri{obj} |
|00001330| 61 6e 64 20 5c 76 61 72 | 69 69 7b 6f 62 6a 7d 20 |and \var|ii{obj} |
|00001340| 61 72 65 20 62 6f 74 68 | 20 63 68 61 72 61 63 74 |are both| charact|
|00001350| 65 72 73 20 61 6e 64 20 | 61 72 65 20 74 68 65 20 |ers and |are the |
|00001360| 73 61 6d 65 0a 63 68 61 | 72 61 63 74 65 72 20 61 |same.cha|racter a|
|00001370| 63 63 6f 72 64 69 6e 67 | 20 74 6f 20 74 68 65 20 |ccording| to the |
|00001380| 5c 69 64 65 7b 63 68 61 | 72 3d 3f 7d 20 70 72 6f |\ide{cha|r=?} pro|
|00001390| 63 65 64 75 72 65 0a 28 | 73 65 63 74 69 6f 6e 7e |cedure.(|section~|
|000013a0| 5c 72 65 66 7b 63 68 61 | 72 61 63 74 65 72 73 65 |\ref{cha|racterse|
|000013b0| 63 74 69 6f 6e 7d 29 2e | 0a 0a 5c 69 74 65 6d 20 |ction}).|..\item |
|000013c0| 62 6f 74 68 20 5c 76 61 | 72 69 7b 6f 62 6a 7d 20 |both \va|ri{obj} |
|000013d0| 61 6e 64 20 5c 76 61 72 | 69 69 7b 6f 62 6a 7d 20 |and \var|ii{obj} |
|000013e0| 61 72 65 20 74 68 65 20 | 65 6d 70 74 79 20 6c 69 |are the |empty li|
|000013f0| 73 74 2e 0a 0a 5c 69 74 | 65 6d 20 5c 76 61 72 69 |st...\it|em \vari|
|00001400| 7b 6f 62 6a 7d 20 61 6e | 64 20 5c 76 61 72 69 69 |{obj} an|d \varii|
|00001410| 7b 6f 62 6a 7d 20 61 72 | 65 20 70 61 69 72 73 2c |{obj} ar|e pairs,|
|00001420| 20 76 65 63 74 6f 72 73 | 2c 20 6f 72 20 73 74 72 | vectors|, or str|
|00001430| 69 6e 67 73 20 74 68 61 | 74 20 64 65 6e 6f 74 65 |ings tha|t denote|
|00001440| 20 74 68 65 0a 73 61 6d | 65 20 6c 6f 63 61 74 69 | the.sam|e locati|
|00001450| 6f 6e 73 20 69 6e 20 74 | 68 65 20 73 74 6f 72 65 |ons in t|he store|
|00001460| 20 28 73 65 63 74 69 6f | 6e 7e 5c 72 65 66 7b 73 | (sectio|n~\ref{s|
|00001470| 74 6f 72 61 67 65 6d 6f | 64 65 6c 7d 29 2e 0a 0a |toragemo|del})...|
|00001480| 5c 69 74 65 6d 20 5c 76 | 61 72 69 7b 6f 62 6a 7d |\item \v|ari{obj}|
|00001490| 20 61 6e 64 20 5c 76 61 | 72 69 69 7b 6f 62 6a 7d | and \va|rii{obj}|
|000014a0| 20 61 72 65 20 70 72 6f | 63 65 64 75 72 65 73 20 | are pro|cedures |
|000014b0| 77 68 6f 73 65 20 6c 6f | 63 61 74 69 6f 6e 20 74 |whose lo|cation t|
|000014c0| 61 67 73 20 61 72 65 0a | 65 71 75 61 6c 20 28 73 |ags are.|equal (s|
|000014d0| 65 63 74 69 6f 6e 7e 5c | 72 65 66 7b 6c 61 6d 62 |ection~\|ref{lamb|
|000014e0| 64 61 7d 29 2e 0a 5c 65 | 6e 64 7b 69 74 65 6d 69 |da})..\e|nd{itemi|
|000014f0| 7a 65 7d 0a 0a 54 68 65 | 20 5c 69 64 65 7b 65 71 |ze}..The| \ide{eq|
|00001500| 76 3f 7d 20 70 72 6f 63 | 65 64 75 72 65 20 72 65 |v?} proc|edure re|
|00001510| 74 75 72 6e 73 20 5c 73 | 63 68 66 61 6c 73 65 7b |turns \s|chfalse{|
|00001520| 7d 20 69 66 3a 0a 0a 5c | 62 65 67 69 6e 7b 69 74 |} if:..\|begin{it|
|00001530| 65 6d 69 7a 65 7d 0a 5c | 69 74 65 6d 20 5c 76 61 |emize}.\|item \va|
|00001540| 72 69 7b 6f 62 6a 7d 20 | 61 6e 64 20 5c 76 61 72 |ri{obj} |and \var|
|00001550| 69 69 7b 6f 62 6a 7d 20 | 61 72 65 20 6f 66 20 64 |ii{obj} |are of d|
|00001560| 69 66 66 65 72 65 6e 74 | 20 74 79 70 65 73 0a 28 |ifferent| types.(|
|00001570| 73 65 63 74 69 6f 6e 7e | 5c 72 65 66 7b 64 69 73 |section~|\ref{dis|
|00001580| 6a 6f 69 6e 74 6e 65 73 | 73 7d 29 2e 0a 0a 5c 69 |jointnes|s})...\i|
|00001590| 74 65 6d 20 6f 6e 65 20 | 6f 66 20 5c 76 61 72 69 |tem one |of \vari|
|000015a0| 7b 6f 62 6a 7d 20 61 6e | 64 20 5c 76 61 72 69 69 |{obj} an|d \varii|
|000015b0| 7b 6f 62 6a 7d 20 69 73 | 20 5c 73 63 68 74 72 75 |{obj} is| \schtru|
|000015c0| 65 7b 7d 20 62 75 74 20 | 74 68 65 20 6f 74 68 65 |e{} but |the othe|
|000015d0| 72 20 69 73 0a 5c 73 63 | 68 66 61 6c 73 65 7b 7d |r is.\sc|hfalse{}|
|000015e0| 2e 0a 0a 5c 69 74 65 6d | 20 5c 76 61 72 69 7b 6f |...\item| \vari{o|
|000015f0| 62 6a 7d 20 61 6e 64 20 | 5c 76 61 72 69 69 7b 6f |bj} and |\varii{o|
|00001600| 62 6a 7d 20 61 72 65 20 | 73 79 6d 62 6f 6c 73 20 |bj} are |symbols |
|00001610| 62 75 74 0a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |but..\be|gin{sche|
|00001620| 6d 65 7d 0a 28 73 74 72 | 69 6e 67 3d 3f 20 28 73 |me}.(str|ing=? (s|
|00001630| 79 6d 62 6f 6c 2d 3e 73 | 74 72 69 6e 67 20 5c 76 |ymbol->s|tring \v|
|00001640| 61 72 69 7b 6f 62 6a 7d | 29 0a 20 20 20 20 20 20 |ari{obj}|). |
|00001650| 20 20 20 20 28 73 79 6d | 62 6f 6c 2d 3e 73 74 72 | (sym|bol->str|
|00001660| 69 6e 67 20 5c 76 61 72 | 69 69 7b 6f 62 6a 7d 29 |ing \var|ii{obj})|
|00001670| 29 0a 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 66 |). \e|v \schf|
|00001680| 61 6c 73 65 25 0a 5c 65 | 6e 64 7b 73 63 68 65 6d |alse%.\e|nd{schem|
|00001690| 65 7d 0a 0a 5c 69 74 65 | 6d 20 6f 6e 65 20 6f 66 |e}..\ite|m one of|
|000016a0| 20 5c 76 61 72 69 7b 6f | 62 6a 7d 20 61 6e 64 20 | \vari{o|bj} and |
|000016b0| 5c 76 61 72 69 69 7b 6f | 62 6a 7d 20 69 73 20 61 |\varii{o|bj} is a|
|000016c0| 6e 20 65 78 61 63 74 20 | 6e 75 6d 62 65 72 20 62 |n exact |number b|
|000016d0| 75 74 20 74 68 65 20 6f | 74 68 65 72 0a 69 73 20 |ut the o|ther.is |
|000016e0| 61 6e 20 69 6e 65 78 61 | 63 74 20 6e 75 6d 62 65 |an inexa|ct numbe|
|000016f0| 72 2e 0a 0a 5c 69 74 65 | 6d 20 5c 76 61 72 69 7b |r...\ite|m \vari{|
|00001700| 6f 62 6a 7d 20 61 6e 64 | 20 5c 76 61 72 69 69 7b |obj} and| \varii{|
|00001710| 6f 62 6a 7d 20 61 72 65 | 20 6e 75 6d 62 65 72 73 |obj} are| numbers|
|00001720| 20 66 6f 72 20 77 68 69 | 63 68 20 74 68 65 20 5c | for whi|ch the \|
|00001730| 69 64 65 7b 3d 7d 0a 70 | 72 6f 63 65 64 75 72 65 |ide{=}.p|rocedure|
|00001740| 20 72 65 74 75 72 6e 73 | 20 5c 73 63 68 66 61 6c | returns| \schfal|
|00001750| 73 65 7b 7d 2e 0a 0a 5c | 69 74 65 6d 20 5c 76 61 |se{}...\|item \va|
|00001760| 72 69 7b 6f 62 6a 7d 20 | 61 6e 64 20 5c 76 61 72 |ri{obj} |and \var|
|00001770| 69 69 7b 6f 62 6a 7d 20 | 61 72 65 20 63 68 61 72 |ii{obj} |are char|
|00001780| 61 63 74 65 72 73 20 66 | 6f 72 20 77 68 69 63 68 |acters f|or which|
|00001790| 20 74 68 65 20 5c 69 64 | 65 7b 63 68 61 72 3d 3f | the \id|e{char=?|
|000017a0| 7d 0a 70 72 6f 63 65 64 | 75 72 65 20 72 65 74 75 |}.proced|ure retu|
|000017b0| 72 6e 73 20 5c 73 63 68 | 66 61 6c 73 65 7b 7d 2e |rns \sch|false{}.|
|000017c0| 0a 0a 5c 69 74 65 6d 20 | 6f 6e 65 20 6f 66 20 5c |..\item |one of \|
|000017d0| 76 61 72 69 7b 6f 62 6a | 7d 20 61 6e 64 20 5c 76 |vari{obj|} and \v|
|000017e0| 61 72 69 69 7b 6f 62 6a | 7d 20 69 73 20 74 68 65 |arii{obj|} is the|
|000017f0| 20 65 6d 70 74 79 20 6c | 69 73 74 20 62 75 74 20 | empty l|ist but |
|00001800| 74 68 65 20 6f 74 68 65 | 72 0a 69 73 20 6e 6f 74 |the othe|r.is not|
|00001810| 2e 0a 0a 5c 69 74 65 6d | 20 5c 76 61 72 69 7b 6f |...\item| \vari{o|
|00001820| 62 6a 7d 20 61 6e 64 20 | 5c 76 61 72 69 69 7b 6f |bj} and |\varii{o|
|00001830| 62 6a 7d 20 61 72 65 20 | 70 61 69 72 73 2c 20 76 |bj} are |pairs, v|
|00001840| 65 63 74 6f 72 73 2c 20 | 6f 72 20 73 74 72 69 6e |ectors, |or strin|
|00001850| 67 73 20 74 68 61 74 20 | 64 65 6e 6f 74 65 0a 64 |gs that |denote.d|
|00001860| 69 73 74 69 6e 63 74 20 | 6c 6f 63 61 74 69 6f 6e |istinct |location|
|00001870| 73 2e 0a 0a 5c 69 74 65 | 6d 20 5c 76 61 72 69 7b |s...\ite|m \vari{|
|00001880| 6f 62 6a 7d 20 61 6e 64 | 20 5c 76 61 72 69 69 7b |obj} and| \varii{|
|00001890| 6f 62 6a 7d 20 61 72 65 | 20 70 72 6f 63 65 64 75 |obj} are| procedu|
|000018a0| 72 65 73 20 74 68 61 74 | 20 77 6f 75 6c 64 20 62 |res that| would b|
|000018b0| 65 68 61 76 65 20 64 69 | 66 66 65 72 65 6e 74 6c |ehave di|fferentl|
|000018c0| 79 0a 28 72 65 74 75 72 | 6e 20 61 20 64 69 66 66 |y.(retur|n a diff|
|000018d0| 65 72 65 6e 74 20 76 61 | 6c 75 65 20 6f 72 20 68 |erent va|lue or h|
|000018e0| 61 76 65 20 64 69 66 66 | 65 72 65 6e 74 20 73 69 |ave diff|erent si|
|000018f0| 64 65 20 65 66 66 65 63 | 74 73 29 20 66 6f 72 20 |de effec|ts) for |
|00001900| 73 6f 6d 65 20 61 72 67 | 75 6d 65 6e 74 73 2e 0a |some arg|uments..|
|00001910| 0a 5c 65 6e 64 7b 69 74 | 65 6d 69 7a 65 7d 0a 0a |.\end{it|emize}..|
|00001920| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 28 |\begin{s|cheme}.(|
|00001930| 65 71 76 3f 20 27 61 20 | 27 61 29 20 20 20 20 20 |eqv? 'a |'a) |
|00001940| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001950| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 28 65 |\ev \sc|htrue.(e|
|00001960| 71 76 3f 20 27 61 20 27 | 62 29 20 20 20 20 20 20 |qv? 'a '|b) |
|00001970| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c | | \|
|00001980| 65 76 20 20 5c 73 63 68 | 66 61 6c 73 65 0a 28 65 |ev \sch|false.(e|
|00001990| 71 76 3f 20 32 20 32 29 | 20 20 20 20 20 20 20 20 |qv? 2 2)| |
|000019a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c | | \|
|000019b0| 65 76 20 20 5c 73 63 68 | 74 72 75 65 0a 28 65 71 |ev \sch|true.(eq|
|000019c0| 76 3f 20 27 28 29 20 27 | 28 29 29 20 20 20 20 20 |v? '() '|()) |
|000019d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 | | \e|
|000019e0| 76 20 20 5c 73 63 68 74 | 72 75 65 0a 28 65 71 76 |v \scht|rue.(eqv|
|000019f0| 3f 20 31 30 30 30 30 30 | 30 30 30 20 31 30 30 30 |? 100000|000 1000|
|00001a00| 30 30 30 30 30 29 20 20 | 20 20 20 20 20 5c 65 76 |00000) | \ev|
|00001a10| 20 20 5c 73 63 68 74 72 | 75 65 0a 28 65 71 76 3f | \schtr|ue.(eqv?|
|00001a20| 20 28 63 6f 6e 73 20 31 | 20 32 29 20 28 63 6f 6e | (cons 1| 2) (con|
|00001a30| 73 20 31 20 32 29 29 20 | 20 20 20 20 5c 65 76 20 |s 1 2)) | \ev |
|00001a40| 20 5c 73 63 68 66 61 6c | 73 65 0a 28 65 71 76 3f | \schfal|se.(eqv?|
|00001a50| 20 28 6c 61 6d 62 64 61 | 20 28 29 20 31 29 0a 20 | (lambda| () 1). |
|00001a60| 20 20 20 20 20 28 6c 61 | 6d 62 64 61 20 28 29 20 | (la|mbda () |
|00001a70| 32 29 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |2)) | |
|00001a80| 5c 65 76 20 20 5c 73 63 | 68 66 61 6c 73 65 0a 28 |\ev \sc|hfalse.(|
|00001a90| 65 71 76 3f 20 5c 23 66 | 20 27 6e 69 6c 29 20 20 |eqv? \#f| 'nil) |
|00001aa0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001ab0| 5c 65 76 20 20 5c 73 63 | 68 66 61 6c 73 65 0a 28 |\ev \sc|hfalse.(|
|00001ac0| 6c 65 74 20 28 28 70 20 | 28 6c 61 6d 62 64 61 20 |let ((p |(lambda |
|00001ad0| 28 78 29 20 78 29 29 29 | 0a 20 20 28 65 71 76 3f |(x) x)))|. (eqv?|
|00001ae0| 20 70 20 70 29 29 09 09 | 20 20 20 20 20 20 20 20 | p p))..| |
|00001af0| 20 5c 65 76 20 20 5c 73 | 63 68 74 72 75 65 25 0a | \ev \s|chtrue%.|
|00001b00| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 54 68 |\end{sch|eme}..Th|
|00001b10| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 65 78 61 6d |e follow|ing exam|
|00001b20| 70 6c 65 73 20 69 6c 6c | 75 73 74 72 61 74 65 20 |ples ill|ustrate |
|00001b30| 63 61 73 65 73 20 69 6e | 20 77 68 69 63 68 20 74 |cases in| which t|
|00001b40| 68 65 20 61 62 6f 76 65 | 20 72 75 6c 65 73 20 64 |he above| rules d|
|00001b50| 6f 0a 6e 6f 74 20 66 75 | 6c 6c 79 20 73 70 65 63 |o.not fu|lly spec|
|00001b60| 69 66 79 20 74 68 65 20 | 62 65 68 61 76 69 6f 72 |ify the |behavior|
|00001b70| 20 6f 66 20 5c 69 64 65 | 7b 65 71 76 3f 7d 2e 20 | of \ide|{eqv?}. |
|00001b80| 20 41 6c 6c 20 74 68 61 | 74 20 63 61 6e 20 62 65 | All tha|t can be|
|00001b90| 20 73 61 69 64 0a 61 62 | 6f 75 74 20 73 75 63 68 | said.ab|out such|
|00001ba0| 20 63 61 73 65 73 20 69 | 73 20 74 68 61 74 20 74 | cases i|s that t|
|00001bb0| 68 65 20 76 61 6c 75 65 | 20 72 65 74 75 72 6e 65 |he value| returne|
|00001bc0| 64 20 62 79 20 5c 69 64 | 65 7b 65 71 76 3f 7d 20 |d by \id|e{eqv?} |
|00001bd0| 6d 75 73 74 20 62 65 20 | 61 0a 62 6f 6f 6c 65 61 |must be |a.boolea|
|00001be0| 6e 2e 0a 0a 5c 62 65 67 | 69 6e 7b 73 63 68 65 6d |n...\beg|in{schem|
|00001bf0| 65 7d 0a 28 65 71 76 3f | 20 22 22 20 22 22 29 20 |e}.(eqv?| "" "") |
|00001c00| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00001c10| 20 5c 75 6e 73 70 65 63 | 69 66 69 65 64 0a 28 65 | \unspec|ified.(e|
|00001c20| 71 76 3f 20 27 5c 23 28 | 29 20 27 5c 23 28 29 29 |qv? '\#(|) '\#())|
|00001c30| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 75 | | \ev \u|
|00001c40| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 65 71 76 3f |nspecifi|ed.(eqv?|
|00001c50| 20 28 6c 61 6d 62 64 61 | 20 28 78 29 20 78 29 0a | (lambda| (x) x).|
|00001c60| 20 20 20 20 20 20 28 6c | 61 6d 62 64 61 20 28 78 | (l|ambda (x|
|00001c70| 29 20 78 29 29 20 20 20 | 20 5c 65 76 20 20 5c 75 |) x)) | \ev \u|
|00001c80| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 65 71 76 3f |nspecifi|ed.(eqv?|
|00001c90| 20 28 6c 61 6d 62 64 61 | 20 28 78 29 20 78 29 0a | (lambda| (x) x).|
|00001ca0| 20 20 20 20 20 20 28 6c | 61 6d 62 64 61 20 28 79 | (l|ambda (y|
|00001cb0| 29 20 79 29 29 20 20 20 | 20 5c 65 76 20 20 5c 75 |) y)) | \ev \u|
|00001cc0| 6e 73 70 65 63 69 66 69 | 65 64 25 0a 5c 65 6e 64 |nspecifi|ed%.\end|
|00001cd0| 7b 73 63 68 65 6d 65 7d | 0a 0a 54 68 65 20 6e 65 |{scheme}|..The ne|
|00001ce0| 78 74 20 73 65 74 20 6f | 66 20 65 78 61 6d 70 6c |xt set o|f exampl|
|00001cf0| 65 73 20 73 68 6f 77 73 | 20 74 68 65 20 75 73 65 |es shows| the use|
|00001d00| 20 6f 66 20 5c 69 64 65 | 7b 65 71 76 3f 7d 5c 20 | of \ide|{eqv?}\ |
|00001d10| 77 69 74 68 20 70 72 6f | 63 65 64 75 72 65 73 0a |with pro|cedures.|
|00001d20| 74 68 61 74 20 68 61 76 | 65 20 6c 6f 63 61 6c 20 |that hav|e local |
|00001d30| 73 74 61 74 65 2e 20 20 | 5c 69 64 65 7b 47 65 6e |state. |\ide{Gen|
|00001d40| 2d 63 6f 75 6e 74 65 72 | 7d 20 6d 75 73 74 20 72 |-counter|} must r|
|00001d50| 65 74 75 72 6e 20 61 20 | 64 69 73 74 69 6e 63 74 |eturn a |distinct|
|00001d60| 0a 70 72 6f 63 65 64 75 | 72 65 20 65 76 65 72 79 |.procedu|re every|
|00001d70| 20 74 69 6d 65 2c 20 73 | 69 6e 63 65 20 65 61 63 | time, s|ince eac|
|00001d80| 68 20 70 72 6f 63 65 64 | 75 72 65 20 68 61 73 20 |h proced|ure has |
|00001d90| 69 74 73 20 6f 77 6e 20 | 69 6e 74 65 72 6e 61 6c |its own |internal|
|00001da0| 20 63 6f 75 6e 74 65 72 | 2e 0a 5c 69 64 65 7b 47 | counter|..\ide{G|
|00001db0| 65 6e 2d 6c 6f 73 65 72 | 7d 2c 20 68 6f 77 65 76 |en-loser|}, howev|
|00001dc0| 65 72 2c 20 72 65 74 75 | 72 6e 73 20 65 71 75 69 |er, retu|rns equi|
|00001dd0| 76 61 6c 65 6e 74 20 70 | 72 6f 63 65 64 75 72 65 |valent p|rocedure|
|00001de0| 73 20 65 61 63 68 20 74 | 69 6d 65 2c 20 73 69 6e |s each t|ime, sin|
|00001df0| 63 65 0a 74 68 65 20 6c | 6f 63 61 6c 20 73 74 61 |ce.the l|ocal sta|
|00001e00| 74 65 20 64 6f 65 73 20 | 6e 6f 74 20 61 66 66 65 |te does |not affe|
|00001e10| 63 74 20 74 68 65 20 76 | 61 6c 75 65 20 6f 72 20 |ct the v|alue or |
|00001e20| 73 69 64 65 20 65 66 66 | 65 63 74 73 20 6f 66 20 |side eff|ects of |
|00001e30| 74 68 65 0a 70 72 6f 63 | 65 64 75 72 65 73 2e 0a |the.proc|edures..|
|00001e40| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00001e50| 28 64 65 66 69 6e 65 20 | 67 65 6e 2d 63 6f 75 6e |(define |gen-coun|
|00001e60| 74 65 72 0a 20 20 28 6c | 61 6d 62 64 61 20 28 29 |ter. (l|ambda ()|
|00001e70| 0a 20 20 20 20 28 6c 65 | 74 20 28 28 6e 20 30 29 |. (le|t ((n 0)|
|00001e80| 29 0a 20 20 20 20 20 20 | 28 6c 61 6d 62 64 61 20 |). |(lambda |
|00001e90| 28 29 20 28 73 65 74 21 | 20 6e 20 28 2b 20 6e 20 |() (set!| n (+ n |
|00001ea0| 31 29 29 20 6e 29 29 29 | 29 0a 28 6c 65 74 20 28 |1)) n)))|).(let (|
|00001eb0| 28 67 20 28 67 65 6e 2d | 63 6f 75 6e 74 65 72 29 |(g (gen-|counter)|
|00001ec0| 29 29 0a 20 20 28 65 71 | 76 3f 20 67 20 67 29 29 |)). (eq|v? g g))|
|00001ed0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|00001ee0| 5c 73 63 68 74 72 75 65 | 0a 28 65 71 76 3f 20 28 |\schtrue|.(eqv? (|
|00001ef0| 67 65 6e 2d 63 6f 75 6e | 74 65 72 29 20 28 67 65 |gen-coun|ter) (ge|
|00001f00| 6e 2d 63 6f 75 6e 74 65 | 72 29 29 0a 20 20 20 20 |n-counte|r)). |
|00001f10| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001f20| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 66 61 6c | \ev | \schfal|
|00001f30| 73 65 0a 28 64 65 66 69 | 6e 65 20 67 65 6e 2d 6c |se.(defi|ne gen-l|
|00001f40| 6f 73 65 72 0a 20 20 28 | 6c 61 6d 62 64 61 20 28 |oser. (|lambda (|
|00001f50| 29 0a 20 20 20 20 28 6c | 65 74 20 28 28 6e 20 30 |). (l|et ((n 0|
|00001f60| 29 29 0a 20 20 20 20 20 | 20 28 6c 61 6d 62 64 61 |)). | (lambda|
|00001f70| 20 28 29 20 28 73 65 74 | 21 20 6e 20 28 2b 20 6e | () (set|! n (+ n|
|00001f80| 20 31 29 29 20 32 37 29 | 29 29 29 0a 28 6c 65 74 | 1)) 27)|))).(let|
|00001f90| 20 28 28 67 20 28 67 65 | 6e 2d 6c 6f 73 65 72 29 | ((g (ge|n-loser)|
|00001fa0| 29 29 0a 20 20 28 65 71 | 76 3f 20 67 20 67 29 29 |)). (eq|v? g g))|
|00001fb0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|00001fc0| 5c 73 63 68 74 72 75 65 | 0a 28 65 71 76 3f 20 28 |\schtrue|.(eqv? (|
|00001fd0| 67 65 6e 2d 6c 6f 73 65 | 72 29 20 28 67 65 6e 2d |gen-lose|r) (gen-|
|00001fe0| 6c 6f 73 65 72 29 29 0a | 20 20 20 20 20 20 20 20 |loser)).| |
|00001ff0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002000| 5c 65 76 20 20 5c 75 6e | 73 70 65 63 69 66 69 65 |\ev \un|specifie|
|00002010| 64 0a 0a 28 6c 65 74 72 | 65 63 20 28 28 66 20 28 |d..(letr|ec ((f (|
|00002020| 6c 61 6d 62 64 61 20 28 | 29 20 28 69 66 20 28 65 |lambda (|) (if (e|
|00002030| 71 76 3f 20 66 20 67 29 | 20 27 62 6f 74 68 20 27 |qv? f g)| 'both '|
|00002040| 66 29 29 29 0a 20 20 20 | 20 20 20 20 20 20 28 67 |f))). | (g|
|00002050| 20 28 6c 61 6d 62 64 61 | 20 28 29 20 28 69 66 20 | (lambda| () (if |
|00002060| 28 65 71 76 3f 20 66 20 | 67 29 20 27 62 6f 74 68 |(eqv? f |g) 'both|
|00002070| 20 27 67 29 29 29 0a 20 | 20 28 65 71 76 3f 20 66 | 'g))). | (eqv? f|
|00002080| 20 67 29 29 0a 20 20 20 | 20 20 20 20 20 20 20 20 | g)). | |
|00002090| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|000020a0| 20 20 5c 75 6e 73 70 65 | 63 69 66 69 65 64 0a 0a | \unspe|cified..|
|000020b0| 28 6c 65 74 72 65 63 20 | 28 28 66 20 28 6c 61 6d |(letrec |((f (lam|
|000020c0| 62 64 61 20 28 29 20 28 | 69 66 20 28 65 71 76 3f |bda () (|if (eqv?|
|000020d0| 20 66 20 67 29 20 27 66 | 20 27 62 6f 74 68 29 29 | f g) 'f| 'both))|
|000020e0| 29 0a 20 20 20 20 20 20 | 20 20 20 28 67 20 28 6c |). | (g (l|
|000020f0| 61 6d 62 64 61 20 28 29 | 20 28 69 66 20 28 65 71 |ambda ()| (if (eq|
|00002100| 76 3f 20 66 20 67 29 20 | 27 67 20 27 62 6f 74 68 |v? f g) |'g 'both|
|00002110| 29 29 29 0a 20 20 28 65 | 71 76 3f 20 66 20 67 29 |))). (e|qv? f g)|
|00002120| 29 0a 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |). | |
|00002130| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c | | \ev \|
|00002140| 73 63 68 66 61 6c 73 65 | 25 0a 5c 65 6e 64 7b 73 |schfalse|%.\end{s|
|00002150| 63 68 65 6d 65 7d 0a 0a | 4f 62 6a 65 63 74 73 20 |cheme}..|Objects |
|00002160| 6f 66 20 64 69 73 74 69 | 6e 63 74 20 74 79 70 65 |of disti|nct type|
|00002170| 73 20 6d 75 73 74 20 6e | 65 76 65 72 20 62 65 20 |s must n|ever be |
|00002180| 72 65 67 61 72 64 65 64 | 20 61 73 20 74 68 65 20 |regarded| as the |
|00002190| 73 61 6d 65 20 6f 62 6a | 65 63 74 2c 0a 65 78 63 |same obj|ect,.exc|
|000021a0| 65 70 74 20 74 68 61 74 | 20 5c 73 63 68 66 61 6c |ept that| \schfal|
|000021b0| 73 65 7b 7d 20 61 6e 64 | 20 74 68 65 20 65 6d 70 |se{} and| the emp|
|000021c0| 74 79 20 6c 69 73 74 5c | 69 6e 64 65 78 7b 65 6d |ty list\|index{em|
|000021d0| 70 74 79 20 6c 69 73 74 | 7d 20 61 72 65 20 70 65 |pty list|} are pe|
|000021e0| 72 6d 69 74 74 65 64 20 | 74 6f 20 62 65 0a 69 64 |rmitted |to be.id|
|000021f0| 65 6e 74 69 63 61 6c 2e | 0a 0a 5c 62 65 67 69 6e |entical.|..\begin|
|00002200| 7b 73 63 68 65 6d 65 7d | 0a 28 65 71 76 3f 20 27 |{scheme}|.(eqv? '|
|00002210| 28 29 20 5c 73 63 68 66 | 61 6c 73 65 29 20 20 20 |() \schf|alse) |
|00002220| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00002230| 65 64 25 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d |ed%.\end|{scheme}|
|00002240| 0a 0a 53 69 6e 63 65 20 | 69 74 20 69 73 20 61 6e |..Since |it is an|
|00002250| 20 65 72 72 6f 72 20 74 | 6f 20 6d 6f 64 69 66 79 | error t|o modify|
|00002260| 20 63 6f 6e 73 74 61 6e | 74 20 6f 62 6a 65 63 74 | constan|t object|
|00002270| 73 20 28 74 68 6f 73 65 | 20 72 65 74 75 72 6e 65 |s (those| returne|
|00002280| 64 20 62 79 0a 6c 69 74 | 65 72 61 6c 20 65 78 70 |d by.lit|eral exp|
|00002290| 72 65 73 73 69 6f 6e 73 | 29 2c 20 69 6d 70 6c 65 |ressions|), imple|
|000022a0| 6d 65 6e 74 61 74 69 6f | 6e 73 20 61 72 65 20 70 |mentatio|ns are p|
|000022b0| 65 72 6d 69 74 74 65 64 | 2c 20 74 68 6f 75 67 68 |ermitted|, though|
|000022c0| 20 6e 6f 74 0a 72 65 71 | 75 69 72 65 64 2c 20 74 | not.req|uired, t|
|000022d0| 6f 20 73 68 61 72 65 20 | 73 74 72 75 63 74 75 72 |o share |structur|
|000022e0| 65 20 62 65 74 77 65 65 | 6e 20 63 6f 6e 73 74 61 |e betwee|n consta|
|000022f0| 6e 74 73 20 77 68 65 72 | 65 20 61 70 70 72 6f 70 |nts wher|e approp|
|00002300| 72 69 61 74 65 2e 20 20 | 54 68 75 73 0a 74 68 65 |riate. |Thus.the|
|00002310| 20 76 61 6c 75 65 20 6f | 66 20 5c 69 64 65 7b 65 | value o|f \ide{e|
|00002320| 71 76 3f 7d 20 6f 6e 20 | 63 6f 6e 73 74 61 6e 74 |qv?} on |constant|
|00002330| 73 20 69 73 20 73 6f 6d | 65 74 69 6d 65 73 0a 69 |s is som|etimes.i|
|00002340| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 2d 64 65 |mplement|ation-de|
|00002350| 70 65 6e 64 65 6e 74 2e | 0a 0a 5c 62 65 67 69 6e |pendent.|..\begin|
|00002360| 7b 73 63 68 65 6d 65 7d | 0a 28 6c 65 74 20 28 28 |{scheme}|.(let ((|
|00002370| 78 20 27 28 61 29 29 29 | 0a 20 20 28 65 71 76 3f |x '(a)))|. (eqv?|
|00002380| 20 78 20 78 29 29 20 20 | 20 20 20 20 20 20 20 20 | x x)) | |
|00002390| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c | | \ev \|
|000023a0| 73 63 68 74 72 75 65 0a | 28 65 71 76 3f 20 27 28 |schtrue.|(eqv? '(|
|000023b0| 61 29 20 27 28 61 29 29 | 20 20 20 20 20 20 20 20 |a) '(a))| |
|000023c0| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 75 | | \ev \u|
|000023d0| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 65 71 76 3f |nspecifi|ed.(eqv?|
|000023e0| 20 22 61 22 20 22 61 22 | 29 20 20 20 20 20 20 20 | "a" "a"|) |
|000023f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00002400| 20 5c 75 6e 73 70 65 63 | 69 66 69 65 64 0a 28 65 | \unspec|ified.(e|
|00002410| 71 76 3f 20 27 28 62 29 | 20 28 63 64 72 20 27 28 |qv? '(b)| (cdr '(|
|00002420| 61 20 62 29 29 29 09 20 | 5c 65 76 20 20 5c 75 6e |a b))). |\ev \un|
|00002430| 73 70 65 63 69 66 69 65 | 64 25 0a 5c 65 6e 64 7b |specifie|d%.\end{|
|00002440| 73 63 68 65 6d 65 7d 0a | 0a 5c 62 65 67 69 6e 7b |scheme}.|.\begin{|
|00002450| 72 61 74 69 6f 6e 61 6c | 65 7d 20 0a 54 68 65 20 |rational|e} .The |
|00002460| 61 62 6f 76 65 20 64 65 | 66 69 6e 69 74 69 6f 6e |above de|finition|
|00002470| 20 6f 66 20 5c 69 64 65 | 7b 65 71 76 3f 7d 20 61 | of \ide|{eqv?} a|
|00002480| 6c 6c 6f 77 73 20 69 6d | 70 6c 65 6d 65 6e 74 61 |llows im|plementa|
|00002490| 74 69 6f 6e 73 20 6c 61 | 74 69 74 75 64 65 20 69 |tions la|titude i|
|000024a0| 6e 0a 74 68 65 69 72 20 | 74 72 65 61 74 6d 65 6e |n.their |treatmen|
|000024b0| 74 20 6f 66 20 70 72 6f | 63 65 64 75 72 65 73 20 |t of pro|cedures |
|000024c0| 61 6e 64 20 6c 69 74 65 | 72 61 6c 73 3a 20 20 69 |and lite|rals: i|
|000024d0| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 73 20 61 |mplement|ations a|
|000024e0| 72 65 20 66 72 65 65 0a | 65 69 74 68 65 72 20 74 |re free.|either t|
|000024f0| 6f 20 64 65 74 65 63 74 | 20 6f 72 20 74 6f 20 66 |o detect| or to f|
|00002500| 61 69 6c 20 74 6f 20 64 | 65 74 65 63 74 20 74 68 |ail to d|etect th|
|00002510| 61 74 20 74 77 6f 20 70 | 72 6f 63 65 64 75 72 65 |at two p|rocedure|
|00002520| 73 20 6f 72 20 74 77 6f | 20 6c 69 74 65 72 61 6c |s or two| literal|
|00002530| 73 0a 61 72 65 20 65 71 | 75 69 76 61 6c 65 6e 74 |s.are eq|uivalent|
|00002540| 20 74 6f 20 65 61 63 68 | 20 6f 74 68 65 72 2c 20 | to each| other, |
|00002550| 61 6e 64 20 63 61 6e 20 | 64 65 63 69 64 65 20 77 |and can |decide w|
|00002560| 68 65 74 68 65 72 20 6f | 72 20 6e 6f 74 20 74 6f |hether o|r not to|
|00002570| 0a 6d 65 72 67 65 20 72 | 65 70 72 65 73 65 6e 74 |.merge r|epresent|
|00002580| 61 74 69 6f 6e 73 20 6f | 66 20 65 71 75 69 76 61 |ations o|f equiva|
|00002590| 6c 65 6e 74 20 6f 62 6a | 65 63 74 73 20 62 79 20 |lent obj|ects by |
|000025a0| 75 73 69 6e 67 20 74 68 | 65 20 73 61 6d 65 20 70 |using th|e same p|
|000025b0| 6f 69 6e 74 65 72 20 6f | 72 0a 62 69 74 20 70 61 |ointer o|r.bit pa|
|000025c0| 74 74 65 72 6e 20 74 6f | 20 72 65 70 72 65 73 65 |ttern to| represe|
|000025d0| 6e 74 20 62 6f 74 68 2e | 0a 5c 65 6e 64 7b 72 61 |nt both.|.\end{ra|
|000025e0| 74 69 6f 6e 61 6c 65 7d | 0a 0a 5c 65 6e 64 7b 65 |tionale}|..\end{e|
|000025f0| 6e 74 72 79 7d 0a 0a 0a | 5c 62 65 67 69 6e 7b 65 |ntry}...|\begin{e|
|00002600| 6e 74 72 79 7d 7b 25 0a | 5c 70 72 6f 74 6f 7b 65 |ntry}{%.|\proto{e|
|00002610| 71 3f 7d 7b 20 5c 76 61 | 72 69 7b 6f 62 6a 7d 20 |q?}{ \va|ri{obj} |
|00002620| 5c 76 61 72 69 69 7b 6f | 62 6a 7d 7d 7b 65 73 73 |\varii{o|bj}}{ess|
|00002630| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|00002640| 7d 7d 0a 0a 5c 69 64 65 | 7b 45 71 3f 7d 5c 20 69 |}}..\ide|{Eq?}\ i|
|00002650| 73 20 73 69 6d 69 6c 61 | 72 20 74 6f 20 5c 69 64 |s simila|r to \id|
|00002660| 65 7b 65 71 76 3f 7d 5c | 20 65 78 63 65 70 74 20 |e{eqv?}\| except |
|00002670| 74 68 61 74 20 69 6e 20 | 73 6f 6d 65 20 63 61 73 |that in |some cas|
|00002680| 65 73 20 69 74 20 69 73 | 0a 63 61 70 61 62 6c 65 |es it is|.capable|
|00002690| 20 6f 66 20 64 69 73 63 | 65 72 6e 69 6e 67 20 64 | of disc|erning d|
|000026a0| 69 73 74 69 6e 63 74 69 | 6f 6e 73 20 66 69 6e 65 |istincti|ons fine|
|000026b0| 72 20 74 68 61 6e 20 74 | 68 6f 73 65 20 64 65 74 |r than t|hose det|
|000026c0| 65 63 74 61 62 6c 65 20 | 62 79 0a 5c 69 64 65 7b |ectable |by.\ide{|
|000026d0| 65 71 76 3f 7d 2e 0a 0a | 5c 76 65 73 74 20 5c 69 |eqv?}...|\vest \i|
|000026e0| 64 65 7b 45 71 3f 7d 5c | 20 61 6e 64 20 5c 69 64 |de{Eq?}\| and \id|
|000026f0| 65 7b 65 71 76 3f 7d 5c | 20 61 72 65 20 67 75 61 |e{eqv?}\| are gua|
|00002700| 72 61 6e 74 65 65 64 20 | 74 6f 20 68 61 76 65 20 |ranteed |to have |
|00002710| 74 68 65 20 73 61 6d 65 | 0a 62 65 68 61 76 69 6f |the same|.behavio|
|00002720| 72 20 6f 6e 20 73 79 6d | 62 6f 6c 73 2c 20 62 6f |r on sym|bols, bo|
|00002730| 6f 6c 65 61 6e 73 2c 20 | 74 68 65 20 65 6d 70 74 |oleans, |the empt|
|00002740| 79 20 6c 69 73 74 2c 20 | 70 61 69 72 73 2c 20 61 |y list, |pairs, a|
|00002750| 6e 64 20 6e 6f 6e 2d 65 | 6d 70 74 79 0a 73 74 72 |nd non-e|mpty.str|
|00002760| 69 6e 67 73 20 61 6e 64 | 20 76 65 63 74 6f 72 73 |ings and| vectors|
|00002770| 2e 20 20 5c 69 64 65 7b | 45 71 3f 7d 27 73 20 62 |. \ide{|Eq?}'s b|
|00002780| 65 68 61 76 69 6f 72 20 | 6f 6e 20 6e 75 6d 62 65 |ehavior |on numbe|
|00002790| 72 73 20 61 6e 64 20 63 | 68 61 72 61 63 74 65 72 |rs and c|haracter|
|000027a0| 73 20 69 73 0a 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |s is.imp|lementat|
|000027b0| 69 6f 6e 2d 64 65 70 65 | 6e 64 65 6e 74 2c 20 62 |ion-depe|ndent, b|
|000027c0| 75 74 20 69 74 20 77 69 | 6c 6c 20 61 6c 77 61 79 |ut it wi|ll alway|
|000027d0| 73 20 72 65 74 75 72 6e | 20 65 69 74 68 65 72 20 |s return| either |
|000027e0| 74 72 75 65 20 6f 72 0a | 66 61 6c 73 65 2c 20 61 |true or.|false, a|
|000027f0| 6e 64 20 77 69 6c 6c 20 | 72 65 74 75 72 6e 20 74 |nd will |return t|
|00002800| 72 75 65 20 6f 6e 6c 79 | 20 77 68 65 6e 20 5c 69 |rue only| when \i|
|00002810| 64 65 7b 65 71 76 3f 7d | 5c 20 77 6f 75 6c 64 20 |de{eqv?}|\ would |
|00002820| 61 6c 73 6f 20 72 65 74 | 75 72 6e 0a 74 72 75 65 |also ret|urn.true|
|00002830| 2e 20 20 5c 69 64 65 7b | 45 71 3f 7d 20 6d 61 79 |. \ide{|Eq?} may|
|00002840| 20 61 6c 73 6f 20 62 65 | 68 61 76 65 20 64 69 66 | also be|have dif|
|00002850| 66 65 72 65 6e 74 6c 79 | 20 66 72 6f 6d 20 5c 69 |ferently| from \i|
|00002860| 64 65 7b 65 71 76 3f 7d | 20 6f 6e 20 65 6d 70 74 |de{eqv?}| on empt|
|00002870| 79 0a 76 65 63 74 6f 72 | 73 20 61 6e 64 20 65 6d |y.vector|s and em|
|00002880| 70 74 79 20 73 74 72 69 | 6e 67 73 2e 0a 0a 5c 62 |pty stri|ngs...\b|
|00002890| 65 67 69 6e 7b 73 63 68 | 65 6d 65 7d 0a 28 65 71 |egin{sch|eme}.(eq|
|000028a0| 3f 20 27 61 20 27 61 29 | 20 20 20 20 20 20 20 20 |? 'a 'a)| |
|000028b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|000028c0| 20 20 5c 73 63 68 74 72 | 75 65 0a 28 65 71 3f 20 | \schtr|ue.(eq? |
|000028d0| 27 28 61 29 20 27 28 61 | 29 29 20 20 20 20 20 20 |'(a) '(a|)) |
|000028e0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|000028f0| 5c 75 6e 73 70 65 63 69 | 66 69 65 64 0a 28 65 71 |\unspeci|fied.(eq|
|00002900| 3f 20 28 6c 69 73 74 20 | 27 61 29 20 28 6c 69 73 |? (list |'a) (lis|
|00002910| 74 20 27 61 29 29 20 20 | 20 20 20 20 20 5c 65 76 |t 'a)) | \ev|
|00002920| 20 20 5c 73 63 68 66 61 | 6c 73 65 0a 28 65 71 3f | \schfa|lse.(eq?|
|00002930| 20 22 61 22 20 22 61 22 | 29 20 20 20 20 20 20 20 | "a" "a"|) |
|00002940| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00002950| 20 5c 75 6e 73 70 65 63 | 69 66 69 65 64 0a 28 65 | \unspec|ified.(e|
|00002960| 71 3f 20 22 22 20 22 22 | 29 20 20 20 20 20 20 20 |q? "" ""|) |
|00002970| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 | | \e|
|00002980| 76 20 20 5c 75 6e 73 70 | 65 63 69 66 69 65 64 0a |v \unsp|ecified.|
|00002990| 28 65 71 3f 20 27 28 29 | 20 27 28 29 29 20 20 20 |(eq? '()| '()) |
|000029a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000029b0| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 28 65 |\ev \sc|htrue.(e|
|000029c0| 71 3f 20 32 20 32 29 20 | 20 20 20 20 20 20 20 20 |q? 2 2) | |
|000029d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 | | \e|
|000029e0| 76 20 20 5c 75 6e 73 70 | 65 63 69 66 69 65 64 0a |v \unsp|ecified.|
|000029f0| 28 65 71 3f 20 5c 23 5c | 62 61 63 6b 77 68 61 63 |(eq? \#\|backwhac|
|00002a00| 6b 7b 7d 41 20 5c 23 5c | 62 61 63 6b 77 68 61 63 |k{}A \#\|backwhac|
|00002a10| 6b 7b 7d 41 29 20 5c 65 | 76 20 20 5c 75 6e 73 70 |k{}A) \e|v \unsp|
|00002a20| 65 63 69 66 69 65 64 0a | 28 65 71 3f 20 63 61 72 |ecified.|(eq? car|
|00002a30| 20 63 61 72 29 20 20 20 | 20 20 20 20 20 20 20 20 | car) | |
|00002a40| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00002a50| 68 74 72 75 65 0a 28 6c | 65 74 20 28 28 6e 20 28 |htrue.(l|et ((n (|
|00002a60| 2b 20 32 20 33 29 29 29 | 0a 20 20 28 65 71 3f 20 |+ 2 3)))|. (eq? |
|00002a70| 6e 20 6e 29 29 20 20 20 | 20 20 20 5c 65 76 20 20 |n n)) | \ev |
|00002a80| 5c 75 6e 73 70 65 63 69 | 66 69 65 64 0a 28 6c 65 |\unspeci|fied.(le|
|00002a90| 74 20 28 28 78 20 27 28 | 61 29 29 29 0a 20 20 28 |t ((x '(|a))). (|
|00002aa0| 65 71 3f 20 78 20 78 29 | 29 20 20 20 20 20 20 5c |eq? x x)|) \|
|00002ab0| 65 76 20 20 5c 73 63 68 | 74 72 75 65 0a 28 6c 65 |ev \sch|true.(le|
|00002ac0| 74 20 28 28 78 20 27 5c | 23 28 29 29 29 0a 20 20 |t ((x '\|#())). |
|00002ad0| 28 65 71 3f 20 78 20 78 | 29 29 20 20 20 20 20 20 |(eq? x x|)) |
|00002ae0| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 28 6c |\ev \sc|htrue.(l|
|00002af0| 65 74 20 28 28 70 20 28 | 6c 61 6d 62 64 61 20 28 |et ((p (|lambda (|
|00002b00| 78 29 20 78 29 29 29 0a | 20 20 28 65 71 3f 20 70 |x) x))).| (eq? p|
|00002b10| 20 70 29 29 20 20 20 20 | 20 20 5c 65 76 20 20 5c | p)) | \ev \|
|00002b20| 73 63 68 74 72 75 65 25 | 0a 5c 65 6e 64 7b 73 63 |schtrue%|.\end{sc|
|00002b30| 68 65 6d 65 7d 0a 0a 5c | 74 6f 64 6f 7b 4e 65 65 |heme}..\|todo{Nee|
|00002b40| 64 73 20 74 6f 20 62 65 | 20 65 78 70 6c 61 69 6e |ds to be| explain|
|00002b50| 65 64 20 62 65 74 74 65 | 72 20 61 62 6f 76 65 2e |ed bette|r above.|
|00002b60| 20 20 48 6f 77 20 63 61 | 6e 20 74 68 69 73 20 62 | How ca|n this b|
|00002b70| 65 20 6d 61 64 65 20 74 | 6f 20 62 65 0a 6e 6f 74 |e made t|o be.not|
|00002b80| 20 63 6f 6e 66 75 73 69 | 6e 67 3f 20 20 41 20 74 | confusi|ng? A t|
|00002b90| 61 62 6c 65 20 6d 61 79 | 62 65 3f 7d 0a 0a 5c 62 |able may|be?}..\b|
|00002ba0| 65 67 69 6e 7b 72 61 74 | 69 6f 6e 61 6c 65 7d 20 |egin{rat|ionale} |
|00002bb0| 49 74 20 77 69 6c 6c 20 | 75 73 75 61 6c 6c 79 20 |It will |usually |
|00002bc0| 62 65 20 70 6f 73 73 69 | 62 6c 65 20 74 6f 20 69 |be possi|ble to i|
|00002bd0| 6d 70 6c 65 6d 65 6e 74 | 20 5c 69 64 65 7b 65 71 |mplement| \ide{eq|
|00002be0| 3f 7d 5c 20 6d 75 63 68 | 0a 6d 6f 72 65 20 65 66 |?}\ much|.more ef|
|00002bf0| 66 69 63 69 65 6e 74 6c | 79 20 74 68 61 6e 20 5c |ficientl|y than \|
|00002c00| 69 64 65 7b 65 71 76 3f | 7d 2c 20 66 6f 72 20 65 |ide{eqv?|}, for e|
|00002c10| 78 61 6d 70 6c 65 2c 20 | 61 73 20 61 20 73 69 6d |xample, |as a sim|
|00002c20| 70 6c 65 20 70 6f 69 6e | 74 65 72 0a 63 6f 6d 70 |ple poin|ter.comp|
|00002c30| 61 72 69 73 6f 6e 20 69 | 6e 73 74 65 61 64 20 6f |arison i|nstead o|
|00002c40| 66 20 61 73 20 73 6f 6d | 65 20 6d 6f 72 65 20 63 |f as som|e more c|
|00002c50| 6f 6d 70 6c 69 63 61 74 | 65 64 20 6f 70 65 72 61 |omplicat|ed opera|
|00002c60| 74 69 6f 6e 2e 20 20 4f | 6e 65 20 72 65 61 73 6f |tion. O|ne reaso|
|00002c70| 6e 20 69 73 0a 74 68 61 | 74 20 69 74 20 6d 61 79 |n is.tha|t it may|
|00002c80| 20 6e 6f 74 20 62 65 20 | 70 6f 73 73 69 62 6c 65 | not be |possible|
|00002c90| 20 74 6f 20 63 6f 6d 70 | 75 74 65 20 5c 69 64 65 | to comp|ute \ide|
|00002ca0| 7b 65 71 76 3f 7d 5c 20 | 6f 66 20 74 77 6f 20 6e |{eqv?}\ |of two n|
|00002cb0| 75 6d 62 65 72 73 20 69 | 6e 0a 63 6f 6e 73 74 61 |umbers i|n.consta|
|00002cc0| 6e 74 20 74 69 6d 65 2c | 20 77 68 65 72 65 61 73 |nt time,| whereas|
|00002cd0| 20 5c 69 64 65 7b 65 71 | 3f 7d 5c 20 69 6d 70 6c | \ide{eq|?}\ impl|
|00002ce0| 65 6d 65 6e 74 65 64 20 | 61 73 20 70 6f 69 6e 74 |emented |as point|
|00002cf0| 65 72 20 63 6f 6d 70 61 | 72 69 73 6f 6e 20 77 69 |er compa|rison wi|
|00002d00| 6c 6c 0a 61 6c 77 61 79 | 73 20 66 69 6e 69 73 68 |ll.alway|s finish|
|00002d10| 20 69 6e 20 63 6f 6e 73 | 74 61 6e 74 20 74 69 6d | in cons|tant tim|
|00002d20| 65 2e 20 20 5c 69 64 65 | 7b 45 71 3f 7d 5c 20 6d |e. \ide|{Eq?}\ m|
|00002d30| 61 79 20 62 65 20 75 73 | 65 64 20 6c 69 6b 65 20 |ay be us|ed like |
|00002d40| 5c 69 64 65 7b 65 71 76 | 3f 7d 5c 0a 69 6e 20 61 |\ide{eqv|?}\.in a|
|00002d50| 70 70 6c 69 63 61 74 69 | 6f 6e 73 20 75 73 69 6e |pplicati|ons usin|
|00002d60| 67 20 70 72 6f 63 65 64 | 75 72 65 73 20 74 6f 20 |g proced|ures to |
|00002d70| 69 6d 70 6c 65 6d 65 6e | 74 20 6f 62 6a 65 63 74 |implemen|t object|
|00002d80| 73 20 77 69 74 68 20 73 | 74 61 74 65 20 73 69 6e |s with s|tate sin|
|00002d90| 63 65 0a 69 74 20 6f 62 | 65 79 73 20 74 68 65 20 |ce.it ob|eys the |
|00002da0| 73 61 6d 65 20 63 6f 6e | 73 74 72 61 69 6e 74 73 |same con|straints|
|00002db0| 20 61 73 20 5c 69 64 65 | 7b 65 71 76 3f 7d 2e 0a | as \ide|{eqv?}..|
|00002dc0| 5c 65 6e 64 7b 72 61 74 | 69 6f 6e 61 6c 65 7d 0a |\end{rat|ionale}.|
|00002dd0| 0a 5c 65 6e 64 7b 65 6e | 74 72 79 7d 0a 0a 0a 5c |.\end{en|try}...\|
|00002de0| 62 65 67 69 6e 7b 65 6e | 74 72 79 7d 7b 25 0a 5c |begin{en|try}{%.\|
|00002df0| 70 72 6f 74 6f 7b 65 71 | 75 61 6c 3f 7d 7b 20 5c |proto{eq|ual?}{ \|
|00002e00| 76 61 72 69 7b 6f 62 6a | 7d 20 5c 76 61 72 69 69 |vari{obj|} \varii|
|00002e10| 7b 6f 62 6a 7d 7d 7b 65 | 73 73 65 6e 74 69 61 6c |{obj}}{e|ssential|
|00002e20| 20 70 72 6f 63 65 64 75 | 72 65 7d 7d 0a 0a 5c 69 | procedu|re}}..\i|
|00002e30| 64 65 7b 45 71 75 61 6c | 3f 7d 20 72 65 63 75 72 |de{Equal|?} recur|
|00002e40| 73 69 76 65 6c 79 20 63 | 6f 6d 70 61 72 65 73 20 |sively c|ompares |
|00002e50| 74 68 65 20 63 6f 6e 74 | 65 6e 74 73 20 6f 66 20 |the cont|ents of |
|00002e60| 70 61 69 72 73 2c 20 76 | 65 63 74 6f 72 73 2c 20 |pairs, v|ectors, |
|00002e70| 61 6e 64 0a 73 74 72 69 | 6e 67 73 2c 20 61 70 70 |and.stri|ngs, app|
|00002e80| 6c 79 69 6e 67 20 5c 69 | 64 65 7b 65 71 76 3f 7d |lying \i|de{eqv?}|
|00002e90| 20 6f 6e 20 6f 74 68 65 | 72 20 6f 62 6a 65 63 74 | on othe|r object|
|00002ea0| 73 20 73 75 63 68 20 61 | 73 20 6e 75 6d 62 65 72 |s such a|s number|
|00002eb0| 73 20 61 6e 64 20 73 79 | 6d 62 6f 6c 73 2e 0a 41 |s and sy|mbols..A|
|00002ec0| 20 72 75 6c 65 20 6f 66 | 20 74 68 75 6d 62 20 69 | rule of| thumb i|
|00002ed0| 73 20 74 68 61 74 20 6f | 62 6a 65 63 74 73 20 61 |s that o|bjects a|
|00002ee0| 72 65 20 67 65 6e 65 72 | 61 6c 6c 79 20 5c 69 64 |re gener|ally \id|
|00002ef0| 65 7b 65 71 75 61 6c 3f | 7d 20 69 66 20 74 68 65 |e{equal?|} if the|
|00002f00| 79 20 70 72 69 6e 74 0a | 74 68 65 20 73 61 6d 65 |y print.|the same|
|00002f10| 2e 20 20 5c 69 64 65 7b | 45 71 75 61 6c 3f 7d 5c |. \ide{|Equal?}\|
|00002f20| 20 6d 61 79 20 66 61 69 | 6c 20 74 6f 20 74 65 72 | may fai|l to ter|
|00002f30| 6d 69 6e 61 74 65 20 69 | 66 20 69 74 73 20 61 72 |minate i|f its ar|
|00002f40| 67 75 6d 65 6e 74 73 20 | 61 72 65 0a 63 69 72 63 |guments |are.circ|
|00002f50| 75 6c 61 72 20 64 61 74 | 61 20 73 74 72 75 63 74 |ular dat|a struct|
|00002f60| 75 72 65 73 2e 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |ures...\|begin{sc|
|00002f70| 68 65 6d 65 7d 0a 28 65 | 71 75 61 6c 3f 20 27 61 |heme}.(e|qual? 'a|
|00002f80| 20 27 61 29 20 20 20 20 | 20 20 20 20 20 20 20 20 | 'a) | |
|00002f90| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 74 | \e|v \scht|
|00002fa0| 72 75 65 0a 28 65 71 75 | 61 6c 3f 20 27 28 61 29 |rue.(equ|al? '(a)|
|00002fb0| 20 27 28 61 29 29 20 20 | 20 20 20 20 20 20 20 20 | '(a)) | |
|00002fc0| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 74 72 75 | \ev | \schtru|
|00002fd0| 65 0a 28 65 71 75 61 6c | 3f 20 27 28 61 20 28 62 |e.(equal|? '(a (b|
|00002fe0| 29 20 63 29 0a 20 20 20 | 20 20 20 20 20 27 28 61 |) c). | '(a|
|00002ff0| 20 28 62 29 20 63 29 29 | 20 20 20 20 20 20 20 20 | (b) c))| |
|00003000| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 74 72 | \ev| \schtr|
|00003010| 75 65 0a 28 65 71 75 61 | 6c 3f 20 22 61 62 63 22 |ue.(equa|l? "abc"|
|00003020| 20 22 61 62 63 22 29 20 | 20 20 20 20 20 20 20 20 | "abc") | |
|00003030| 20 20 20 5c 65 76 20 20 | 5c 73 63 68 74 72 75 65 | \ev |\schtrue|
|00003040| 0a 28 65 71 75 61 6c 3f | 20 32 20 32 29 20 20 20 |.(equal?| 2 2) |
|00003050| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003060| 20 5c 65 76 20 20 5c 73 | 63 68 74 72 75 65 0a 28 | \ev \s|chtrue.(|
|00003070| 65 71 75 61 6c 3f 20 28 | 6d 61 6b 65 2d 76 65 63 |equal? (|make-vec|
|00003080| 74 6f 72 20 35 20 27 61 | 29 0a 20 20 20 20 20 20 |tor 5 'a|). |
|00003090| 20 20 28 6d 61 6b 65 2d | 76 65 63 74 6f 72 20 35 | (make-|vector 5|
|000030a0| 20 27 61 29 29 20 20 20 | 20 20 5c 65 76 20 20 5c | 'a)) | \ev \|
|000030b0| 73 63 68 74 72 75 65 0a | 28 65 71 75 61 6c 3f 20 |schtrue.|(equal? |
|000030c0| 28 6c 61 6d 62 64 61 20 | 28 78 29 20 78 29 0a 20 |(lambda |(x) x). |
|000030d0| 20 20 20 20 20 20 20 28 | 6c 61 6d 62 64 61 20 28 | (|lambda (|
|000030e0| 79 29 20 79 29 29 20 20 | 5c 65 76 20 20 5c 75 6e |y) y)) |\ev \un|
|000030f0| 73 70 65 63 69 66 69 65 | 64 25 0a 5c 65 6e 64 7b |specifie|d%.\end{|
|00003100| 73 63 68 65 6d 65 7d 0a | 0a 5c 65 6e 64 7b 65 6e |scheme}.|.\end{en|
|00003110| 74 72 79 7d 0a 0a 0a 5c | 73 65 63 74 69 6f 6e 7b |try}...\|section{|
|00003120| 50 61 69 72 73 20 61 6e | 64 20 6c 69 73 74 73 7d |Pairs an|d lists}|
|00003130| 0a 5c 6c 61 62 65 6c 7b | 6c 69 73 74 73 65 63 74 |.\label{|listsect|
|00003140| 69 6f 6e 7d 0a 0a 41 20 | 5c 64 65 66 69 6e 69 6e |ion}..A |\definin|
|00003150| 67 7b 70 61 69 72 7d 20 | 28 73 6f 6d 65 74 69 6d |g{pair} |(sometim|
|00003160| 65 73 20 63 61 6c 6c 65 | 64 20 61 20 5c 64 65 66 |es calle|d a \def|
|00003170| 69 6e 69 6e 67 7b 64 6f | 74 74 65 64 20 70 61 69 |ining{do|tted pai|
|00003180| 72 7d 29 20 69 73 20 61 | 0a 72 65 63 6f 72 64 20 |r}) is a|.record |
|00003190| 73 74 72 75 63 74 75 72 | 65 20 77 69 74 68 20 74 |structur|e with t|
|000031a0| 77 6f 20 66 69 65 6c 64 | 73 20 63 61 6c 6c 65 64 |wo field|s called|
|000031b0| 20 74 68 65 20 63 61 72 | 20 61 6e 64 20 63 64 72 | the car| and cdr|
|000031c0| 20 66 69 65 6c 64 73 20 | 28 66 6f 72 0a 68 69 73 | fields |(for.his|
|000031d0| 74 6f 72 69 63 61 6c 20 | 72 65 61 73 6f 6e 73 29 |torical |reasons)|
|000031e0| 2e 20 20 50 61 69 72 73 | 20 61 72 65 20 63 72 65 |. Pairs| are cre|
|000031f0| 61 74 65 64 20 62 79 20 | 74 68 65 20 70 72 6f 63 |ated by |the proc|
|00003200| 65 64 75 72 65 20 5c 69 | 64 65 7b 63 6f 6e 73 7d |edure \i|de{cons}|
|00003210| 2e 0a 54 68 65 20 63 61 | 72 20 61 6e 64 20 63 64 |..The ca|r and cd|
|00003220| 72 20 66 69 65 6c 64 73 | 20 61 72 65 20 61 63 63 |r fields| are acc|
|00003230| 65 73 73 65 64 20 62 79 | 20 74 68 65 20 70 72 6f |essed by| the pro|
|00003240| 63 65 64 75 72 65 73 20 | 5c 69 64 65 7b 63 61 72 |cedures |\ide{car|
|00003250| 7d 20 61 6e 64 0a 5c 69 | 64 65 7b 63 64 72 7d 2e |} and.\i|de{cdr}.|
|00003260| 20 20 54 68 65 20 63 61 | 72 20 61 6e 64 20 63 64 | The ca|r and cd|
|00003270| 72 20 66 69 65 6c 64 73 | 20 61 72 65 20 61 73 73 |r fields| are ass|
|00003280| 69 67 6e 65 64 20 62 79 | 20 74 68 65 20 70 72 6f |igned by| the pro|
|00003290| 63 65 64 75 72 65 73 0a | 5c 69 64 65 7b 73 65 74 |cedures.|\ide{set|
|000032a0| 2d 63 61 72 21 7d 5c 20 | 61 6e 64 20 5c 69 64 65 |-car!}\ |and \ide|
|000032b0| 7b 73 65 74 2d 63 64 72 | 21 7d 2e 0a 0a 50 61 69 |{set-cdr|!}...Pai|
|000032c0| 72 73 20 61 72 65 20 75 | 73 65 64 20 70 72 69 6d |rs are u|sed prim|
|000032d0| 61 72 69 6c 79 20 74 6f | 20 72 65 70 72 65 73 65 |arily to| represe|
|000032e0| 6e 74 20 6c 69 73 74 73 | 2e 20 20 41 20 6c 69 73 |nt lists|. A lis|
|000032f0| 74 20 63 61 6e 0a 62 65 | 20 64 65 66 69 6e 65 64 |t can.be| defined|
|00003300| 20 72 65 63 75 72 73 69 | 76 65 6c 79 20 61 73 20 | recursi|vely as |
|00003310| 65 69 74 68 65 72 20 74 | 68 65 20 65 6d 70 74 79 |either t|he empty|
|00003320| 20 6c 69 73 74 5c 69 6e | 64 65 78 7b 65 6d 70 74 | list\in|dex{empt|
|00003330| 79 20 6c 69 73 74 7d 20 | 6f 72 20 61 20 70 61 69 |y list} |or a pai|
|00003340| 72 20 77 68 6f 73 65 0a | 63 64 72 20 69 73 20 61 |r whose.|cdr is a|
|00003350| 20 6c 69 73 74 2e 20 20 | 4d 6f 72 65 20 70 72 65 | list. |More pre|
|00003360| 63 69 73 65 6c 79 2c 20 | 74 68 65 20 73 65 74 20 |cisely, |the set |
|00003370| 6f 66 20 6c 69 73 74 73 | 20 69 73 20 64 65 66 69 |of lists| is defi|
|00003380| 6e 65 64 20 61 73 20 74 | 68 65 20 73 6d 61 6c 6c |ned as t|he small|
|00003390| 65 73 74 0a 73 65 74 20 | 5c 76 61 72 7b 58 7d 20 |est.set |\var{X} |
|000033a0| 73 75 63 68 20 74 68 61 | 74 0a 0a 5c 62 65 67 69 |such tha|t..\begi|
|000033b0| 6e 7b 69 74 65 6d 69 7a | 65 7d 0a 5c 69 74 65 6d |n{itemiz|e}.\item|
|000033c0| 20 54 68 65 20 65 6d 70 | 74 79 20 6c 69 73 74 20 | The emp|ty list |
|000033d0| 69 73 20 69 6e 20 5c 76 | 61 72 7b 58 7d 2e 0a 5c |is in \v|ar{X}..\|
|000033e0| 69 74 65 6d 20 49 66 20 | 5c 76 61 72 7b 6c 69 73 |item If |\var{lis|
|000033f0| 74 7d 20 69 73 20 69 6e | 20 5c 76 61 72 7b 58 7d |t} is in| \var{X}|
|00003400| 2c 20 74 68 65 6e 20 61 | 6e 79 20 70 61 69 72 20 |, then a|ny pair |
|00003410| 77 68 6f 73 65 20 63 64 | 72 20 66 69 65 6c 64 20 |whose cd|r field |
|00003420| 63 6f 6e 74 61 69 6e 73 | 0a 20 20 20 20 20 20 5c |contains|. \|
|00003430| 76 61 72 7b 6c 69 73 74 | 7d 20 69 73 20 61 6c 73 |var{list|} is als|
|00003440| 6f 20 69 6e 20 5c 76 61 | 72 7b 58 7d 2e 0a 5c 65 |o in \va|r{X}..\e|
|00003450| 6e 64 7b 69 74 65 6d 69 | 7a 65 7d 0a 0a 54 68 65 |nd{itemi|ze}..The|
|00003460| 20 6f 62 6a 65 63 74 73 | 20 69 6e 20 74 68 65 20 | objects| in the |
|00003470| 63 61 72 20 66 69 65 6c | 64 73 20 6f 66 20 73 75 |car fiel|ds of su|
|00003480| 63 63 65 73 73 69 76 65 | 20 70 61 69 72 73 20 6f |ccessive| pairs o|
|00003490| 66 20 61 20 6c 69 73 74 | 20 61 72 65 20 74 68 65 |f a list| are the|
|000034a0| 0a 65 6c 65 6d 65 6e 74 | 73 20 6f 66 20 74 68 65 |.element|s of the|
|000034b0| 20 6c 69 73 74 2e 20 20 | 46 6f 72 20 65 78 61 6d | list. |For exam|
|000034c0| 70 6c 65 2c 20 61 20 74 | 77 6f 2d 65 6c 65 6d 65 |ple, a t|wo-eleme|
|000034d0| 6e 74 20 6c 69 73 74 20 | 69 73 20 61 20 70 61 69 |nt list |is a pai|
|000034e0| 72 20 77 68 6f 73 65 20 | 63 61 72 0a 69 73 20 74 |r whose |car.is t|
|000034f0| 68 65 20 66 69 72 73 74 | 20 65 6c 65 6d 65 6e 74 |he first| element|
|00003500| 20 61 6e 64 20 77 68 6f | 73 65 20 63 64 72 20 69 | and who|se cdr i|
|00003510| 73 20 61 20 70 61 69 72 | 20 77 68 6f 73 65 20 63 |s a pair| whose c|
|00003520| 61 72 20 69 73 20 74 68 | 65 20 73 65 63 6f 6e 64 |ar is th|e second|
|00003530| 20 65 6c 65 6d 65 6e 74 | 0a 61 6e 64 20 77 68 6f | element|.and who|
|00003540| 73 65 20 63 64 72 20 69 | 73 20 74 68 65 20 65 6d |se cdr i|s the em|
|00003550| 70 74 79 20 6c 69 73 74 | 2e 20 20 54 68 65 20 6c |pty list|. The l|
|00003560| 65 6e 67 74 68 20 6f 66 | 20 61 20 6c 69 73 74 20 |ength of| a list |
|00003570| 69 73 20 74 68 65 20 6e | 75 6d 62 65 72 20 6f 66 |is the n|umber of|
|00003580| 0a 65 6c 65 6d 65 6e 74 | 73 2c 20 77 68 69 63 68 |.element|s, which|
|00003590| 20 69 73 20 74 68 65 20 | 73 61 6d 65 20 61 73 20 | is the |same as |
|000035a0| 74 68 65 20 6e 75 6d 62 | 65 72 20 6f 66 20 70 61 |the numb|er of pa|
|000035b0| 69 72 73 2e 0a 0a 54 68 | 65 20 65 6d 70 74 79 20 |irs...Th|e empty |
|000035c0| 6c 69 73 74 5c 6d 61 69 | 6e 69 6e 64 65 78 7b 65 |list\mai|nindex{e|
|000035d0| 6d 70 74 79 20 6c 69 73 | 74 7d 20 69 73 20 61 20 |mpty lis|t} is a |
|000035e0| 73 70 65 63 69 61 6c 20 | 6f 62 6a 65 63 74 20 6f |special |object o|
|000035f0| 66 20 69 74 73 20 6f 77 | 6e 20 74 79 70 65 0a 28 |f its ow|n type.(|
|00003600| 69 74 20 69 73 20 6e 6f | 74 20 61 20 70 61 69 72 |it is no|t a pair|
|00003610| 29 3b 20 69 74 20 68 61 | 73 20 6e 6f 20 65 6c 65 |); it ha|s no ele|
|00003620| 6d 65 6e 74 73 20 61 6e | 64 20 69 74 73 20 6c 65 |ments an|d its le|
|00003630| 6e 67 74 68 20 69 73 20 | 7a 65 72 6f 2e 0a 0a 5c |ngth is |zero...\|
|00003640| 62 65 67 69 6e 7b 6e 6f | 74 65 7d 0a 54 68 65 20 |begin{no|te}.The |
|00003650| 61 62 6f 76 65 20 64 65 | 66 69 6e 69 74 69 6f 6e |above de|finition|
|00003660| 73 20 69 6d 70 6c 79 20 | 74 68 61 74 20 61 6c 6c |s imply |that all|
|00003670| 20 6c 69 73 74 73 20 68 | 61 76 65 20 66 69 6e 69 | lists h|ave fini|
|00003680| 74 65 20 6c 65 6e 67 74 | 68 20 61 6e 64 20 61 72 |te lengt|h and ar|
|00003690| 65 0a 74 65 72 6d 69 6e | 61 74 65 64 20 62 79 20 |e.termin|ated by |
|000036a0| 74 68 65 20 65 6d 70 74 | 79 20 6c 69 73 74 2e 0a |the empt|y list..|
|000036b0| 5c 65 6e 64 7b 6e 6f 74 | 65 7d 0a 0a 54 68 65 20 |\end{not|e}..The |
|000036c0| 6d 6f 73 74 20 67 65 6e | 65 72 61 6c 20 6e 6f 74 |most gen|eral not|
|000036d0| 61 74 69 6f 6e 20 28 65 | 78 74 65 72 6e 61 6c 20 |ation (e|xternal |
|000036e0| 72 65 70 72 65 73 65 6e | 74 61 74 69 6f 6e 29 20 |represen|tation) |
|000036f0| 66 6f 72 20 53 63 68 65 | 6d 65 20 70 61 69 72 73 |for Sche|me pairs|
|00003700| 20 69 73 0a 74 68 65 20 | 60 60 64 6f 74 74 65 64 | is.the |``dotted|
|00003710| 27 27 20 6e 6f 74 61 74 | 69 6f 6e 20 5c 68 62 6f |'' notat|ion \hbo|
|00003720| 78 7b 5c 63 66 20 28 5c | 76 61 72 69 7b 63 7d 20 |x{\cf (\|vari{c} |
|00003730| 2e 5c 20 5c 76 61 72 69 | 69 7b 63 7d 29 7d 20 77 |.\ \vari|i{c})} w|
|00003740| 68 65 72 65 0a 5c 76 61 | 72 69 7b 63 7d 20 69 73 |here.\va|ri{c} is|
|00003750| 20 74 68 65 20 76 61 6c | 75 65 20 6f 66 20 74 68 | the val|ue of th|
|00003760| 65 20 63 61 72 20 66 69 | 65 6c 64 20 61 6e 64 20 |e car fi|eld and |
|00003770| 5c 76 61 72 69 69 7b 63 | 7d 20 69 73 20 74 68 65 |\varii{c|} is the|
|00003780| 20 76 61 6c 75 65 20 6f | 66 20 74 68 65 0a 63 64 | value o|f the.cd|
|00003790| 72 20 66 69 65 6c 64 2e | 20 20 46 6f 72 20 65 78 |r field.| For ex|
|000037a0| 61 6d 70 6c 65 20 7b 5c | 63 66 20 28 34 20 2e 5c |ample {\|cf (4 .\|
|000037b0| 20 35 29 7d 20 69 73 20 | 61 20 70 61 69 72 20 77 | 5)} is |a pair w|
|000037c0| 68 6f 73 65 20 63 61 72 | 20 69 73 20 34 20 61 6e |hose car| is 4 an|
|000037d0| 64 20 77 68 6f 73 65 0a | 63 64 72 20 69 73 20 35 |d whose.|cdr is 5|
|000037e0| 2e 20 20 4e 6f 74 65 20 | 74 68 61 74 20 7b 5c 63 |. Note |that {\c|
|000037f0| 66 20 28 34 20 2e 5c 20 | 35 29 7d 20 69 73 20 74 |f (4 .\ |5)} is t|
|00003800| 68 65 20 65 78 74 65 72 | 6e 61 6c 20 72 65 70 72 |he exter|nal repr|
|00003810| 65 73 65 6e 74 61 74 69 | 6f 6e 20 6f 66 20 61 0a |esentati|on of a.|
|00003820| 70 61 69 72 2c 20 6e 6f | 74 20 61 6e 20 65 78 70 |pair, no|t an exp|
|00003830| 72 65 73 73 69 6f 6e 20 | 74 68 61 74 20 65 76 61 |ression |that eva|
|00003840| 6c 75 61 74 65 73 20 74 | 6f 20 61 20 70 61 69 72 |luates t|o a pair|
|00003850| 2e 0a 0a 41 20 6d 6f 72 | 65 20 73 74 72 65 61 6d |...A mor|e stream|
|00003860| 6c 69 6e 65 64 20 6e 6f | 74 61 74 69 6f 6e 20 63 |lined no|tation c|
|00003870| 61 6e 20 62 65 20 75 73 | 65 64 20 66 6f 72 20 6c |an be us|ed for l|
|00003880| 69 73 74 73 3a 20 74 68 | 65 20 65 6c 65 6d 65 6e |ists: th|e elemen|
|00003890| 74 73 20 6f 66 20 74 68 | 65 0a 6c 69 73 74 20 61 |ts of th|e.list a|
|000038a0| 72 65 20 73 69 6d 70 6c | 79 20 65 6e 63 6c 6f 73 |re simpl|y enclos|
|000038b0| 65 64 20 69 6e 20 70 61 | 72 65 6e 74 68 65 73 65 |ed in pa|renthese|
|000038c0| 73 20 61 6e 64 20 73 65 | 70 61 72 61 74 65 64 20 |s and se|parated |
|000038d0| 62 79 20 73 70 61 63 65 | 73 2e 20 20 54 68 65 0a |by space|s. The.|
|000038e0| 65 6d 70 74 79 20 6c 69 | 73 74 5c 69 6e 64 65 78 |empty li|st\index|
|000038f0| 7b 65 6d 70 74 79 20 6c | 69 73 74 7d 20 69 73 20 |{empty l|ist} is |
|00003900| 77 72 69 74 74 65 6e 20 | 7b 5c 74 74 28 29 7d 20 |written |{\tt()} |
|00003910| 2e 20 20 46 6f 72 20 65 | 78 61 6d 70 6c 65 2c 0a |. For e|xample,.|
|00003920| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00003930| 28 61 20 62 20 63 20 64 | 20 65 29 25 0a 5c 65 6e |(a b c d| e)%.\en|
|00003940| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 61 6e 64 0a 0a |d{scheme|}..and..|
|00003950| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 28 |\begin{s|cheme}.(|
|00003960| 61 20 2e 20 28 62 20 2e | 20 28 63 20 2e 20 28 64 |a . (b .| (c . (d|
|00003970| 20 2e 20 28 65 20 2e 20 | 28 29 29 29 29 29 29 25 | . (e . |())))))%|
|00003980| 0a 5c 65 6e 64 7b 73 63 | 68 65 6d 65 7d 0a 0a 61 |.\end{sc|heme}..a|
|00003990| 72 65 20 65 71 75 69 76 | 61 6c 65 6e 74 20 6e 6f |re equiv|alent no|
|000039a0| 74 61 74 69 6f 6e 73 20 | 66 6f 72 20 61 20 6c 69 |tations |for a li|
|000039b0| 73 74 20 6f 66 20 73 79 | 6d 62 6f 6c 73 2e 0a 0a |st of sy|mbols...|
|000039c0| 41 20 63 68 61 69 6e 20 | 6f 66 20 70 61 69 72 73 |A chain |of pairs|
|000039d0| 20 6e 6f 74 20 65 6e 64 | 69 6e 67 20 69 6e 20 74 | not end|ing in t|
|000039e0| 68 65 20 65 6d 70 74 79 | 20 6c 69 73 74 20 69 73 |he empty| list is|
|000039f0| 20 63 61 6c 6c 65 64 20 | 61 6e 0a 5c 64 65 66 69 | called |an.\defi|
|00003a00| 6e 69 6e 67 7b 69 6d 70 | 72 6f 70 65 72 20 6c 69 |ning{imp|roper li|
|00003a10| 73 74 7d 2e 20 20 4e 6f | 74 65 20 74 68 61 74 20 |st}. No|te that |
|00003a20| 61 6e 20 69 6d 70 72 6f | 70 65 72 20 6c 69 73 74 |an impro|per list|
|00003a30| 20 69 73 20 6e 6f 74 20 | 61 20 6c 69 73 74 2e 0a | is not |a list..|
|00003a40| 54 68 65 20 6c 69 73 74 | 20 61 6e 64 20 64 6f 74 |The list| and dot|
|00003a50| 74 65 64 20 6e 6f 74 61 | 74 69 6f 6e 73 20 63 61 |ted nota|tions ca|
|00003a60| 6e 20 62 65 20 63 6f 6d | 62 69 6e 65 64 20 74 6f |n be com|bined to|
|00003a70| 20 72 65 70 72 65 73 65 | 6e 74 0a 69 6d 70 72 6f | represe|nt.impro|
|00003a80| 70 65 72 20 6c 69 73 74 | 73 3a 0a 0a 5c 62 65 67 |per list|s:..\beg|
|00003a90| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 61 20 62 20 |in{schem|e}.(a b |
|00003aa0| 63 20 2e 20 64 29 25 0a | 5c 65 6e 64 7b 73 63 68 |c . d)%.|\end{sch|
|00003ab0| 65 6d 65 7d 0a 0a 69 73 | 20 65 71 75 69 76 61 6c |eme}..is| equival|
|00003ac0| 65 6e 74 20 74 6f 0a 0a | 5c 62 65 67 69 6e 7b 73 |ent to..|\begin{s|
|00003ad0| 63 68 65 6d 65 7d 0a 28 | 61 20 2e 20 28 62 20 2e |cheme}.(|a . (b .|
|00003ae0| 20 28 63 20 2e 20 64 29 | 29 29 25 0a 5c 65 6e 64 | (c . d)|))%.\end|
|00003af0| 7b 73 63 68 65 6d 65 7d | 0a 0a 57 68 65 74 68 65 |{scheme}|..Whethe|
|00003b00| 72 20 61 20 67 69 76 65 | 6e 20 70 61 69 72 20 69 |r a give|n pair i|
|00003b10| 73 20 61 20 6c 69 73 74 | 20 64 65 70 65 6e 64 73 |s a list| depends|
|00003b20| 20 75 70 6f 6e 20 77 68 | 61 74 20 69 73 20 73 74 | upon wh|at is st|
|00003b30| 6f 72 65 64 20 69 6e 20 | 74 68 65 20 63 64 72 0a |ored in |the cdr.|
|00003b40| 66 69 65 6c 64 2e 20 20 | 57 68 65 6e 20 74 68 65 |field. |When the|
|00003b50| 20 5c 69 64 65 7b 73 65 | 74 2d 63 64 72 21 7d 20 | \ide{se|t-cdr!} |
|00003b60| 70 72 6f 63 65 64 75 72 | 65 20 69 73 20 75 73 65 |procedur|e is use|
|00003b70| 64 2c 20 61 6e 20 6f 62 | 6a 65 63 74 20 63 61 6e |d, an ob|ject can|
|00003b80| 20 62 65 20 61 0a 6c 69 | 73 74 20 6f 6e 65 20 6d | be a.li|st one m|
|00003b90| 6f 6d 65 6e 74 20 61 6e | 64 20 6e 6f 74 20 74 68 |oment an|d not th|
|00003ba0| 65 20 6e 65 78 74 3a 0a | 0a 5c 62 65 67 69 6e 7b |e next:.|.\begin{|
|00003bb0| 73 63 68 65 6d 65 7d 0a | 28 64 65 66 69 6e 65 20 |scheme}.|(define |
|00003bc0| 78 20 28 6c 69 73 74 20 | 27 61 20 27 62 20 27 63 |x (list |'a 'b 'c|
|00003bd0| 29 29 0a 28 64 65 66 69 | 6e 65 20 79 20 78 29 0a |)).(defi|ne y x).|
|00003be0| 79 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |y | |
|00003bf0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 28 61 20 | |\ev (a |
|00003c00| 62 20 63 29 0a 28 6c 69 | 73 74 3f 20 79 29 20 20 |b c).(li|st? y) |
|00003c10| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00003c20| 20 20 5c 73 63 68 74 72 | 75 65 0a 28 73 65 74 2d | \schtr|ue.(set-|
|00003c30| 63 64 72 21 20 78 20 34 | 29 20 20 20 20 20 20 20 |cdr! x 4|) |
|00003c40| 20 20 20 5c 65 76 20 20 | 5c 75 6e 73 70 65 63 69 | \ev |\unspeci|
|00003c50| 66 69 65 64 0a 78 20 20 | 20 20 20 20 20 20 20 20 |fied.x | |
|00003c60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00003c70| 20 20 28 61 20 2e 20 34 | 29 0a 28 65 71 76 3f 20 | (a . 4|).(eqv? |
|00003c80| 78 20 79 29 20 20 20 20 | 20 20 20 20 20 20 20 20 |x y) | |
|00003c90| 20 20 5c 65 76 20 20 5c | 73 63 68 74 72 75 65 0a | \ev \|schtrue.|
|00003ca0| 79 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |y | |
|00003cb0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 28 61 20 | |\ev (a |
|00003cc0| 2e 20 34 29 0a 28 6c 69 | 73 74 3f 20 79 29 20 20 |. 4).(li|st? y) |
|00003cd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00003ce0| 20 20 5c 73 63 68 66 61 | 6c 73 65 0a 28 73 65 74 | \schfa|lse.(set|
|00003cf0| 2d 63 64 72 21 20 78 20 | 78 29 20 20 20 20 20 20 |-cdr! x |x) |
|00003d00| 20 20 20 20 5c 65 76 20 | 20 5c 75 6e 73 70 65 63 | \ev | \unspec|
|00003d10| 69 66 69 65 64 0a 28 6c | 69 73 74 3f 20 78 29 20 |ified.(l|ist? x) |
|00003d20| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 | | \e|
|00003d30| 76 20 20 5c 73 63 68 66 | 61 6c 73 65 25 0a 5c 65 |v \schf|alse%.\e|
|00003d40| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 0a 25 49 74 20 |nd{schem|e}..%It |
|00003d50| 69 73 20 6f 66 74 65 6e | 20 63 6f 6e 76 65 6e 69 |is often| conveni|
|00003d60| 65 6e 74 20 74 6f 20 73 | 70 65 61 6b 20 6f 66 20 |ent to s|peak of |
|00003d70| 61 20 68 6f 6d 6f 67 65 | 6e 65 6f 75 73 20 6c 69 |a homoge|neous li|
|00003d80| 73 74 20 6f 66 20 6f 62 | 6a 65 63 74 73 0a 25 6f |st of ob|jects.%o|
|00003d90| 66 20 73 6f 6d 65 20 70 | 61 72 74 69 63 75 6c 61 |f some p|articula|
|00003da0| 72 20 64 61 74 61 20 74 | 79 70 65 2c 20 61 73 20 |r data t|ype, as |
|00003db0| 66 6f 72 20 65 78 61 6d | 70 6c 65 20 5c 68 62 6f |for exam|ple \hbo|
|00003dc0| 78 7b 5c 63 66 20 28 31 | 20 32 20 33 29 7d 20 69 |x{\cf (1| 2 3)} i|
|00003dd0| 73 20 61 20 6c 69 73 74 | 20 6f 66 0a 25 69 6e 74 |s a list| of.%int|
|00003de0| 65 67 65 72 73 2e 20 20 | 54 6f 20 62 65 20 6d 6f |egers. |To be mo|
|00003df0| 72 65 20 70 72 65 63 69 | 73 65 2c 20 73 75 70 70 |re preci|se, supp|
|00003e00| 6f 73 65 20 5c 76 61 72 | 7b 44 7d 20 69 73 20 73 |ose \var|{D} is s|
|00003e10| 6f 6d 65 20 64 61 74 61 | 20 74 79 70 65 2e 20 20 |ome data| type. |
|00003e20| 28 41 6e 79 0a 25 70 72 | 65 64 69 63 61 74 65 20 |(Any.%pr|edicate |
|00003e30| 64 65 66 69 6e 65 73 20 | 61 20 64 61 74 61 20 74 |defines |a data t|
|00003e40| 79 70 65 20 63 6f 6e 73 | 69 73 74 69 6e 67 20 6f |ype cons|isting o|
|00003e50| 66 20 74 68 6f 73 65 20 | 6f 62 6a 65 63 74 73 20 |f those |objects |
|00003e60| 6f 66 20 77 68 69 63 68 | 20 74 68 65 0a 25 70 72 |of which| the.%pr|
|00003e70| 65 64 69 63 61 74 65 20 | 69 73 20 74 72 75 65 2e |edicate |is true.|
|00003e80| 29 20 20 54 68 65 6e 0a | 25 0a 25 5c 62 65 67 69 |) Then.|%.%\begi|
|00003e90| 6e 7b 69 74 65 6d 69 7a | 65 7d 0a 25 5c 69 74 65 |n{itemiz|e}.%\ite|
|00003ea0| 6d 20 54 68 65 20 65 6d | 70 74 79 20 6c 69 73 74 |m The em|pty list|
|00003eb0| 20 69 73 20 61 20 6c 69 | 73 74 20 6f 66 20 5c 76 | is a li|st of \v|
|00003ec0| 61 72 7b 44 7d 2e 0a 25 | 5c 69 74 65 6d 20 49 66 |ar{D}..%|\item If|
|00003ed0| 20 5c 76 61 72 7b 6c 69 | 73 74 7d 20 69 73 20 61 | \var{li|st} is a|
|00003ee0| 20 6c 69 73 74 20 6f 66 | 20 5c 76 61 72 7b 44 7d | list of| \var{D}|
|00003ef0| 2c 20 74 68 65 6e 20 61 | 6e 79 20 70 61 69 72 20 |, then a|ny pair |
|00003f00| 77 68 6f 73 65 20 63 64 | 72 20 69 73 0a 25 20 20 |whose cd|r is.% |
|00003f10| 20 20 20 20 5c 76 61 72 | 7b 6c 69 73 74 7d 20 61 | \var|{list} a|
|00003f20| 6e 64 20 77 68 6f 73 65 | 20 63 61 72 20 69 73 20 |nd whose| car is |
|00003f30| 61 6e 20 65 6c 65 6d 65 | 6e 74 20 6f 66 20 74 68 |an eleme|nt of th|
|00003f40| 65 20 64 61 74 61 20 74 | 79 70 65 20 5c 76 61 72 |e data t|ype \var|
|00003f50| 7b 44 7d 20 69 73 20 61 | 6c 73 6f 20 61 0a 25 20 |{D} is a|lso a.% |
|00003f60| 20 20 20 20 20 6c 69 73 | 74 20 6f 66 20 5c 76 61 | lis|t of \va|
|00003f70| 72 7b 44 7d 2e 0a 25 5c | 69 74 65 6d 20 54 68 65 |r{D}..%\|item The|
|00003f80| 72 65 20 61 72 65 20 6e | 6f 20 6f 74 68 65 72 20 |re are n|o other |
|00003f90| 6c 69 73 74 73 20 6f 66 | 20 5c 76 61 72 7b 44 7d |lists of| \var{D}|
|00003fa0| 2e 0a 25 5c 65 6e 64 7b | 69 74 65 6d 69 7a 65 7d |..%\end{|itemize}|
|00003fb0| 0a 0a 57 69 74 68 69 6e | 20 6c 69 74 65 72 61 6c |..Within| literal|
|00003fc0| 20 65 78 70 72 65 73 73 | 69 6f 6e 73 20 61 6e 64 | express|ions and|
|00003fd0| 20 72 65 70 72 65 73 65 | 6e 74 61 74 69 6f 6e 73 | represe|ntations|
|00003fe0| 20 6f 66 20 6f 62 6a 65 | 63 74 73 20 72 65 61 64 | of obje|cts read|
|00003ff0| 20 62 79 20 74 68 65 0a | 5c 69 64 65 7b 72 65 61 | by the.|\ide{rea|
|00004000| 64 7d 20 70 72 6f 63 65 | 64 75 72 65 2c 20 74 68 |d} proce|dure, th|
|00004010| 65 20 66 6f 72 6d 73 20 | 5c 73 69 6e 67 6c 65 71 |e forms |\singleq|
|00004020| 75 6f 74 65 5c 68 79 70 | 65 72 7b 64 61 74 75 6d |uote\hyp|er{datum|
|00004030| 7d 5c 73 63 68 69 6e 64 | 65 78 7b 27 7d 2c 0a 5c |}\schind|ex{'},.\|
|00004040| 62 61 63 6b 71 75 6f 74 | 65 5c 68 79 70 65 72 7b |backquot|e\hyper{|
|00004050| 64 61 74 75 6d 7d 2c 20 | 7b 5c 74 74 2c 7d 5c 68 |datum}, |{\tt,}\h|
|00004060| 79 70 65 72 7b 64 61 74 | 75 6d 7d 5c 73 63 68 69 |yper{dat|um}\schi|
|00004070| 6e 64 65 78 7b 2c 7d 2c | 20 61 6e 64 0a 7b 5c 74 |ndex{,},| and.{\t|
|00004080| 74 2c 40 7d 5c 68 79 70 | 65 72 7b 64 61 74 75 6d |t,@}\hyp|er{datum|
|00004090| 7d 20 64 65 6e 6f 74 65 | 20 74 77 6f 2d 65 6c 65 |} denote| two-ele|
|000040a0| 5c 2d 6d 65 6e 74 20 6c | 69 73 74 73 20 77 68 6f |\-ment l|ists who|
|000040b0| 73 65 20 66 69 72 73 74 | 20 65 6c 65 6d 65 6e 74 |se first| element|
|000040c0| 73 20 61 72 65 0a 74 68 | 65 20 73 79 6d 62 6f 6c |s are.th|e symbol|
|000040d0| 73 20 5c 69 64 65 7b 71 | 75 6f 74 65 7d 2c 20 5c |s \ide{q|uote}, \|
|000040e0| 69 64 65 7b 71 75 61 73 | 69 71 75 6f 74 65 7d 2c |ide{quas|iquote},|
|000040f0| 20 5c 68 62 6f 78 7b 5c | 69 64 65 7b 75 6e 71 75 | \hbox{\|ide{unqu|
|00004100| 6f 74 65 7d 7d 2c 20 61 | 6e 64 0a 5c 69 64 65 7b |ote}}, a|nd.\ide{|
|00004110| 75 6e 71 75 6f 74 65 2d | 73 70 6c 69 63 69 6e 67 |unquote-|splicing|
|00004120| 7d 2c 20 72 65 73 70 65 | 63 74 69 76 65 6c 79 2e |}, respe|ctively.|
|00004130| 20 20 54 68 65 20 73 65 | 63 6f 6e 64 20 65 6c 65 | The se|cond ele|
|00004140| 6d 65 6e 74 20 69 6e 20 | 65 61 63 68 20 63 61 73 |ment in |each cas|
|00004150| 65 0a 69 73 20 5c 68 79 | 70 65 72 7b 64 61 74 75 |e.is \hy|per{datu|
|00004160| 6d 7d 2e 20 20 54 68 69 | 73 20 63 6f 6e 76 65 6e |m}. Thi|s conven|
|00004170| 74 69 6f 6e 20 69 73 20 | 73 75 70 70 6f 72 74 65 |tion is |supporte|
|00004180| 64 20 73 6f 20 74 68 61 | 74 20 61 72 62 69 74 72 |d so tha|t arbitr|
|00004190| 61 72 79 20 53 63 68 65 | 6d 65 0a 70 72 6f 67 72 |ary Sche|me.progr|
|000041a0| 61 6d 73 20 6d 61 79 20 | 62 65 20 72 65 70 72 65 |ams may |be repre|
|000041b0| 73 65 6e 74 65 64 20 61 | 73 20 6c 69 73 74 73 2e |sented a|s lists.|
|000041c0| 20 20 5c 74 6f 64 6f 7b | 43 61 6e 20 6f 72 20 6e | \todo{|Can or n|
|000041d0| 65 65 64 20 74 68 69 73 | 20 62 65 20 73 74 61 74 |eed this| be stat|
|000041e0| 65 64 0a 6d 6f 72 65 20 | 63 61 72 65 66 75 6c 6c |ed.more |carefull|
|000041f0| 79 3f 7d 20 54 68 61 74 | 20 69 73 2c 20 61 63 63 |y?} That| is, acc|
|00004200| 6f 72 64 69 6e 67 20 74 | 6f 20 53 63 68 65 6d 65 |ording t|o Scheme|
|00004210| 27 73 20 67 72 61 6d 6d | 61 72 2c 20 65 76 65 72 |'s gramm|ar, ever|
|00004220| 79 0a 5c 6d 65 74 61 7b | 65 78 70 72 65 73 73 69 |y.\meta{|expressi|
|00004230| 6f 6e 7d 20 69 73 20 61 | 6c 73 6f 20 61 20 5c 6d |on} is a|lso a \m|
|00004240| 65 74 61 7b 64 61 74 75 | 6d 7d 20 28 73 65 65 20 |eta{datu|m} (see |
|00004250| 73 65 63 74 69 6f 6e 7e | 5c 72 65 66 7b 64 61 74 |section~|\ref{dat|
|00004260| 75 6d 7d 29 2e 0a 41 6d | 6f 6e 67 20 6f 74 68 65 |um})..Am|ong othe|
|00004270| 72 20 74 68 69 6e 67 73 | 2c 20 74 68 69 73 20 70 |r things|, this p|
|00004280| 65 72 6d 69 74 73 20 74 | 68 65 20 75 73 65 20 6f |ermits t|he use o|
|00004290| 66 20 74 68 65 20 5c 69 | 64 65 7b 72 65 61 64 7d |f the \i|de{read}|
|000042a0| 20 70 72 6f 63 65 64 75 | 72 65 20 74 6f 0a 70 61 | procedu|re to.pa|
|000042b0| 72 73 65 20 53 63 68 65 | 6d 65 20 70 72 6f 67 72 |rse Sche|me progr|
|000042c0| 61 6d 73 2e 20 20 53 65 | 65 20 73 65 63 74 69 6f |ams. Se|e sectio|
|000042d0| 6e 7e 5c 72 65 66 7b 65 | 78 74 65 72 6e 61 6c 72 |n~\ref{e|xternalr|
|000042e0| 65 70 73 7d 2e 20 0a 20 | 0a 0a 5c 62 65 67 69 6e |eps}. . |..\begin|
|000042f0| 7b 65 6e 74 72 79 7d 7b | 25 0a 5c 70 72 6f 74 6f |{entry}{|%.\proto|
|00004300| 7b 70 61 69 72 3f 7d 7b | 20 6f 62 6a 7d 7b 65 73 |{pair?}{| obj}{es|
|00004310| 73 65 6e 74 69 61 6c 20 | 70 72 6f 63 65 64 75 72 |sential |procedur|
|00004320| 65 7d 7d 0a 0a 5c 69 64 | 65 7b 50 61 69 72 3f 7d |e}}..\id|e{Pair?}|
|00004330| 20 72 65 74 75 72 6e 73 | 20 5c 73 63 68 74 72 75 | returns| \schtru|
|00004340| 65 7b 7d 20 69 66 20 5c | 76 61 72 7b 6f 62 6a 7d |e{} if \|var{obj}|
|00004350| 20 69 73 20 61 20 70 61 | 69 72 2c 20 61 6e 64 20 | is a pa|ir, and |
|00004360| 6f 74 68 65 72 77 69 73 | 65 0a 72 65 74 75 72 6e |otherwis|e.return|
|00004370| 73 20 5c 73 63 68 66 61 | 6c 73 65 2e 0a 0a 5c 62 |s \schfa|lse...\b|
|00004380| 65 67 69 6e 7b 73 63 68 | 65 6d 65 7d 0a 28 70 61 |egin{sch|eme}.(pa|
|00004390| 69 72 3f 20 27 28 61 20 | 2e 20 62 29 29 20 20 20 |ir? '(a |. b)) |
|000043a0| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 74 72 | \ev| \schtr|
|000043b0| 75 65 0a 28 70 61 69 72 | 3f 20 27 28 61 20 62 20 |ue.(pair|? '(a b |
|000043c0| 63 29 29 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 |c)) | \ev |
|000043d0| 5c 73 63 68 74 72 75 65 | 0a 28 70 61 69 72 3f 20 |\schtrue|.(pair? |
|000043e0| 27 28 29 29 20 20 20 20 | 20 20 20 20 20 20 20 20 |'()) | |
|000043f0| 20 5c 65 76 20 20 5c 73 | 63 68 66 61 6c 73 65 0a | \ev \s|chfalse.|
|00004400| 28 70 61 69 72 3f 20 27 | 5c 23 28 61 20 62 29 29 |(pair? '|\#(a b))|
|00004410| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 73 | | \ev \s|
|00004420| 63 68 66 61 6c 73 65 25 | 0a 5c 65 6e 64 7b 73 63 |chfalse%|.\end{sc|
|00004430| 68 65 6d 65 7d 0a 5c 65 | 6e 64 7b 65 6e 74 72 79 |heme}.\e|nd{entry|
|00004440| 7d 0a 0a 0a 5c 62 65 67 | 69 6e 7b 65 6e 74 72 79 |}...\beg|in{entry|
|00004450| 7d 7b 25 0a 5c 70 72 6f | 74 6f 7b 63 6f 6e 73 7d |}{%.\pro|to{cons}|
|00004460| 7b 20 5c 76 61 72 69 7b | 6f 62 6a 7d 20 5c 76 61 |{ \vari{|obj} \va|
|00004470| 72 69 69 7b 6f 62 6a 7d | 7d 7b 65 73 73 65 6e 74 |rii{obj}|}{essent|
|00004480| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00004490| 0a 52 65 74 75 72 6e 73 | 20 61 20 6e 65 77 6c 79 |.Returns| a newly|
|000044a0| 20 61 6c 6c 6f 63 61 74 | 65 64 20 70 61 69 72 20 | allocat|ed pair |
|000044b0| 77 68 6f 73 65 20 63 61 | 72 20 69 73 20 5c 76 61 |whose ca|r is \va|
|000044c0| 72 69 7b 6f 62 6a 7d 20 | 61 6e 64 20 77 68 6f 73 |ri{obj} |and whos|
|000044d0| 65 20 63 64 72 20 69 73 | 0a 5c 76 61 72 69 69 7b |e cdr is|.\varii{|
|000044e0| 6f 62 6a 7d 2e 20 20 54 | 68 65 20 70 61 69 72 20 |obj}. T|he pair |
|000044f0| 69 73 20 67 75 61 72 61 | 6e 74 65 65 64 20 74 6f |is guara|nteed to|
|00004500| 20 62 65 20 64 69 66 66 | 65 72 65 6e 74 20 28 69 | be diff|erent (i|
|00004510| 6e 20 74 68 65 20 73 65 | 6e 73 65 20 6f 66 0a 5c |n the se|nse of.\|
|00004520| 69 64 65 7b 65 71 76 3f | 7d 29 20 66 72 6f 6d 20 |ide{eqv?|}) from |
|00004530| 65 76 65 72 79 20 65 78 | 69 73 74 69 6e 67 20 6f |every ex|isting o|
|00004540| 62 6a 65 63 74 2e 0a 0a | 5c 62 65 67 69 6e 7b 73 |bject...|\begin{s|
|00004550| 63 68 65 6d 65 7d 0a 28 | 63 6f 6e 73 20 27 61 20 |cheme}.(|cons 'a |
|00004560| 27 28 29 29 20 20 20 20 | 20 20 20 20 20 20 20 5c |'()) | \|
|00004570| 65 76 20 20 28 61 29 0a | 28 63 6f 6e 73 20 27 28 |ev (a).|(cons '(|
|00004580| 61 29 20 27 28 62 20 63 | 20 64 29 29 20 20 20 20 |a) '(b c| d)) |
|00004590| 5c 65 76 20 20 28 28 61 | 29 20 62 20 63 20 64 29 |\ev ((a|) b c d)|
|000045a0| 0a 28 63 6f 6e 73 20 22 | 61 22 20 27 28 62 20 63 |.(cons "|a" '(b c|
|000045b0| 29 29 20 20 20 20 20 20 | 20 5c 65 76 20 20 28 22 |)) | \ev ("|
|000045c0| 61 22 20 62 20 63 29 0a | 28 63 6f 6e 73 20 27 61 |a" b c).|(cons 'a|
|000045d0| 20 33 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | 3) | |
|000045e0| 5c 65 76 20 20 28 61 20 | 2e 20 33 29 0a 28 63 6f |\ev (a |. 3).(co|
|000045f0| 6e 73 20 27 28 61 20 62 | 29 20 27 63 29 20 20 20 |ns '(a b|) 'c) |
|00004600| 20 20 20 20 20 5c 65 76 | 20 20 28 28 61 20 62 29 | \ev| ((a b)|
|00004610| 20 2e 20 63 29 25 0a 5c | 65 6e 64 7b 73 63 68 65 | . c)%.\|end{sche|
|00004620| 6d 65 7d 0a 5c 65 6e 64 | 7b 65 6e 74 72 79 7d 0a |me}.\end|{entry}.|
|00004630| 0a 0a 5c 62 65 67 69 6e | 7b 65 6e 74 72 79 7d 7b |..\begin|{entry}{|
|00004640| 25 0a 5c 70 72 6f 74 6f | 7b 63 61 72 7d 7b 20 70 |%.\proto|{car}{ p|
|00004650| 61 69 72 7d 7b 65 73 73 | 65 6e 74 69 61 6c 20 70 |air}{ess|ential p|
|00004660| 72 6f 63 65 64 75 72 65 | 7d 7d 0a 0a 5c 6e 6f 64 |rocedure|}}..\nod|
|00004670| 6f 6d 61 69 6e 7b 5c 76 | 61 72 7b 50 61 69 72 7d |omain{\v|ar{Pair}|
|00004680| 20 6d 75 73 74 20 62 65 | 20 61 20 70 61 69 72 2e | must be| a pair.|
|00004690| 7d 0a 52 65 74 75 72 6e | 73 20 74 68 65 20 63 6f |}.Return|s the co|
|000046a0| 6e 74 65 6e 74 73 20 6f | 66 20 74 68 65 20 63 61 |ntents o|f the ca|
|000046b0| 72 20 66 69 65 6c 64 20 | 6f 66 20 5c 76 61 72 7b |r field |of \var{|
|000046c0| 70 61 69 72 7d 2e 20 20 | 4e 6f 74 65 20 74 68 61 |pair}. |Note tha|
|000046d0| 74 20 69 74 20 69 73 20 | 61 6e 0a 65 72 72 6f 72 |t it is |an.error|
|000046e0| 20 74 6f 20 74 61 6b 65 | 20 74 68 65 20 63 61 72 | to take| the car|
|000046f0| 20 6f 66 20 74 68 65 20 | 65 6d 70 74 79 20 6c 69 | of the |empty li|
|00004700| 73 74 5c 69 6e 64 65 78 | 7b 65 6d 70 74 79 20 6c |st\index|{empty l|
|00004710| 69 73 74 7d 2e 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |ist}...\|begin{sc|
|00004720| 68 65 6d 65 7d 0a 28 63 | 61 72 20 27 28 61 20 62 |heme}.(c|ar '(a b|
|00004730| 20 63 29 29 20 20 20 20 | 20 20 20 20 20 20 5c 65 | c)) | \e|
|00004740| 76 20 20 61 0a 28 63 61 | 72 20 27 28 28 61 29 20 |v a.(ca|r '((a) |
|00004750| 62 20 63 20 64 29 29 20 | 20 20 20 20 20 5c 65 76 |b c d)) | \ev|
|00004760| 20 20 28 61 29 0a 28 63 | 61 72 20 27 28 31 20 2e | (a).(c|ar '(1 .|
|00004770| 20 32 29 29 20 20 20 20 | 20 20 20 20 20 20 5c 65 | 2)) | \e|
|00004780| 76 20 20 31 0a 28 63 61 | 72 20 27 28 29 29 20 20 |v 1.(ca|r '()) |
|00004790| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|000047a0| 20 20 5c 73 63 68 65 72 | 72 6f 72 25 0a 5c 65 6e | \scher|ror%.\en|
|000047b0| 64 7b 73 63 68 65 6d 65 | 7d 0a 20 0a 5c 65 6e 64 |d{scheme|}. .\end|
|000047c0| 7b 65 6e 74 72 79 7d 0a | 0a 0a 5c 62 65 67 69 6e |{entry}.|..\begin|
|000047d0| 7b 65 6e 74 72 79 7d 7b | 25 0a 5c 70 72 6f 74 6f |{entry}{|%.\proto|
|000047e0| 7b 63 64 72 7d 7b 20 70 | 61 69 72 7d 7b 65 73 73 |{cdr}{ p|air}{ess|
|000047f0| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|00004800| 7d 7d 0a 0a 5c 6e 6f 64 | 6f 6d 61 69 6e 7b 5c 76 |}}..\nod|omain{\v|
|00004810| 61 72 7b 50 61 69 72 7d | 20 6d 75 73 74 20 62 65 |ar{Pair}| must be|
|00004820| 20 61 20 70 61 69 72 2e | 7d 0a 52 65 74 75 72 6e | a pair.|}.Return|
|00004830| 73 20 74 68 65 20 63 6f | 6e 74 65 6e 74 73 20 6f |s the co|ntents o|
|00004840| 66 20 74 68 65 20 63 64 | 72 20 66 69 65 6c 64 20 |f the cd|r field |
|00004850| 6f 66 20 5c 76 61 72 7b | 70 61 69 72 7d 2e 0a 4e |of \var{|pair}..N|
|00004860| 6f 74 65 20 74 68 61 74 | 20 69 74 20 69 73 20 61 |ote that| it is a|
|00004870| 6e 20 65 72 72 6f 72 20 | 74 6f 20 74 61 6b 65 20 |n error |to take |
|00004880| 74 68 65 20 63 64 72 20 | 6f 66 20 74 68 65 20 65 |the cdr |of the e|
|00004890| 6d 70 74 79 20 6c 69 73 | 74 2e 0a 0a 5c 62 65 67 |mpty lis|t...\beg|
|000048a0| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 63 64 72 20 |in{schem|e}.(cdr |
|000048b0| 27 28 28 61 29 20 62 20 | 63 20 64 29 29 20 20 20 |'((a) b |c d)) |
|000048c0| 20 20 20 5c 65 76 20 20 | 28 62 20 63 20 64 29 0a | \ev |(b c d).|
|000048d0| 28 63 64 72 20 27 28 31 | 20 2e 20 32 29 29 20 20 |(cdr '(1| . 2)) |
|000048e0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 32 0a 28 | |\ev 2.(|
|000048f0| 63 64 72 20 27 28 29 29 | 20 20 20 20 20 20 20 20 |cdr '())| |
|00004900| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 73 63 68 | \|ev \sch|
|00004910| 65 72 72 6f 72 25 0a 5c | 65 6e 64 7b 73 63 68 65 |error%.\|end{sche|
|00004920| 6d 65 7d 0a 20 0a 5c 65 | 6e 64 7b 65 6e 74 72 79 |me}. .\e|nd{entry|
|00004930| 7d 0a 0a 0a 5c 62 65 67 | 69 6e 7b 65 6e 74 72 79 |}...\beg|in{entry|
|00004940| 7d 7b 25 0a 5c 70 72 6f | 74 6f 7b 73 65 74 2d 63 |}{%.\pro|to{set-c|
|00004950| 61 72 21 7d 7b 20 70 61 | 69 72 20 6f 62 6a 7d 7b |ar!}{ pa|ir obj}{|
|00004960| 65 73 73 65 6e 74 69 61 | 6c 20 70 72 6f 63 65 64 |essentia|l proced|
|00004970| 75 72 65 7d 7d 0a 0a 5c | 6e 6f 64 6f 6d 61 69 6e |ure}}..\|nodomain|
|00004980| 7b 5c 76 61 72 7b 50 61 | 69 72 7d 20 6d 75 73 74 |{\var{Pa|ir} must|
|00004990| 20 62 65 20 61 20 70 61 | 69 72 2e 7d 20 20 0a 53 | be a pa|ir.} .S|
|000049a0| 74 6f 72 65 73 20 5c 76 | 61 72 7b 6f 62 6a 7d 20 |tores \v|ar{obj} |
|000049b0| 69 6e 20 74 68 65 20 63 | 61 72 20 66 69 65 6c 64 |in the c|ar field|
|000049c0| 20 6f 66 20 5c 76 61 72 | 7b 70 61 69 72 7d 2e 0a | of \var|{pair}..|
|000049d0| 54 68 65 20 76 61 6c 75 | 65 20 72 65 74 75 72 6e |The valu|e return|
|000049e0| 65 64 20 62 79 20 5c 69 | 64 65 7b 73 65 74 2d 63 |ed by \i|de{set-c|
|000049f0| 61 72 21 7d 5c 20 69 73 | 20 75 6e 73 70 65 63 69 |ar!}\ is| unspeci|
|00004a00| 66 69 65 64 2e 20 20 25 | 20 3c 21 3e 0a 25 54 68 |fied. %| <!>.%Th|
|00004a10| 69 73 20 70 72 6f 63 65 | 64 75 72 65 20 63 61 6e |is proce|dure can|
|00004a20| 20 62 65 20 76 65 72 79 | 20 63 6f 6e 66 75 73 69 | be very| confusi|
|00004a30| 6e 67 20 69 66 20 75 73 | 65 64 20 69 6e 64 69 73 |ng if us|ed indis|
|00004a40| 63 72 69 6d 69 6e 61 74 | 65 6c 79 2e 0a 0a 5c 62 |criminat|ely...\b|
|00004a50| 65 67 69 6e 7b 73 63 68 | 65 6d 65 7d 0a 28 64 65 |egin{sch|eme}.(de|
|00004a60| 66 69 6e 65 20 28 66 29 | 20 28 6c 69 73 74 20 27 |fine (f)| (list '|
|00004a70| 6e 6f 74 2d 61 2d 63 6f | 6e 73 74 61 6e 74 2d 6c |not-a-co|nstant-l|
|00004a80| 69 73 74 29 29 0a 28 64 | 65 66 69 6e 65 20 28 67 |ist)).(d|efine (g|
|00004a90| 29 20 27 28 63 6f 6e 73 | 74 61 6e 74 2d 6c 69 73 |) '(cons|tant-lis|
|00004aa0| 74 29 29 0a 28 73 65 74 | 2d 63 61 72 21 20 28 66 |t)).(set|-car! (f|
|00004ab0| 29 20 33 29 20 20 20 20 | 20 20 20 20 20 20 20 20 |) 3) | |
|00004ac0| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00004ad0| 65 64 0a 28 73 65 74 2d | 63 61 72 21 20 28 67 29 |ed.(set-|car! (g)|
|00004ae0| 20 33 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | 3) | |
|00004af0| 5c 65 76 20 20 5c 73 63 | 68 65 72 72 6f 72 25 0a |\ev \sc|herror%.|
|00004b00| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 5c 65 |\end{sch|eme}..\e|
|00004b10| 6e 64 7b 65 6e 74 72 79 | 7d 0a 0a 0a 5c 62 65 67 |nd{entry|}...\beg|
|00004b20| 69 6e 7b 65 6e 74 72 79 | 7d 7b 25 0a 5c 70 72 6f |in{entry|}{%.\pro|
|00004b30| 74 6f 7b 73 65 74 2d 63 | 64 72 21 7d 7b 20 70 61 |to{set-c|dr!}{ pa|
|00004b40| 69 72 20 6f 62 6a 7d 7b | 65 73 73 65 6e 74 69 61 |ir obj}{|essentia|
|00004b50| 6c 20 70 72 6f 63 65 64 | 75 72 65 7d 7d 0a 0a 5c |l proced|ure}}..\|
|00004b60| 6e 6f 64 6f 6d 61 69 6e | 7b 5c 76 61 72 7b 50 61 |nodomain|{\var{Pa|
|00004b70| 69 72 7d 20 6d 75 73 74 | 20 62 65 20 61 20 70 61 |ir} must| be a pa|
|00004b80| 69 72 2e 7d 0a 53 74 6f | 72 65 73 20 5c 76 61 72 |ir.}.Sto|res \var|
|00004b90| 7b 6f 62 6a 7d 20 69 6e | 20 74 68 65 20 63 64 72 |{obj} in| the cdr|
|00004ba0| 20 66 69 65 6c 64 20 6f | 66 20 5c 76 61 72 7b 70 | field o|f \var{p|
|00004bb0| 61 69 72 7d 2e 0a 54 68 | 65 20 76 61 6c 75 65 20 |air}..Th|e value |
|00004bc0| 72 65 74 75 72 6e 65 64 | 20 62 79 20 5c 69 64 65 |returned| by \ide|
|00004bd0| 7b 73 65 74 2d 63 64 72 | 21 7d 5c 20 69 73 20 75 |{set-cdr|!}\ is u|
|00004be0| 6e 73 70 65 63 69 66 69 | 65 64 2e 20 20 25 20 3c |nspecifi|ed. % <|
|00004bf0| 21 3e 0a 25 54 68 69 73 | 20 70 72 6f 63 65 64 75 |!>.%This| procedu|
|00004c00| 72 65 20 63 61 6e 20 62 | 65 20 76 65 72 79 20 63 |re can b|e very c|
|00004c10| 6f 6e 66 75 73 69 6e 67 | 20 69 66 20 75 73 65 64 |onfusing| if used|
|00004c20| 20 69 6e 64 69 73 63 72 | 69 6d 69 6e 61 74 65 6c | indiscr|iminatel|
|00004c30| 79 2e 0a 0a 5c 65 6e 64 | 7b 65 6e 74 72 79 7d 0a |y...\end|{entry}.|
|00004c40| 0a 5c 73 65 74 62 6f 78 | 30 5c 68 62 6f 78 7b 5c |.\setbox|0\hbox{\|
|00004c50| 74 74 28 63 61 64 72 20 | 5c 76 61 72 7b 70 61 69 |tt(cadr |\var{pai|
|00004c60| 72 7d 29 7d 0a 5c 73 65 | 74 62 6f 78 31 5c 68 62 |r})}.\se|tbox1\hb|
|00004c70| 6f 78 7b 65 73 73 65 6e | 74 69 61 6c 20 70 72 6f |ox{essen|tial pro|
|00004c80| 63 65 64 75 72 65 7d 0a | 0a 0a 5c 62 65 67 69 6e |cedure}.|..\begin|
|00004c90| 7b 65 6e 74 72 79 7d 7b | 25 0a 5c 70 72 6f 74 6f |{entry}{|%.\proto|
|00004ca0| 7b 63 61 61 72 7d 7b 20 | 70 61 69 72 7d 7b 65 73 |{caar}{ |pair}{es|
|00004cb0| 73 65 6e 74 69 61 6c 20 | 70 72 6f 63 65 64 75 72 |sential |procedur|
|00004cc0| 65 7d 0a 5c 70 72 6f 74 | 6f 7b 63 61 64 72 7d 7b |e}.\prot|o{cadr}{|
|00004cd0| 20 70 61 69 72 7d 7b 65 | 73 73 65 6e 74 69 61 6c | pair}{e|ssential|
|00004ce0| 20 70 72 6f 63 65 64 75 | 72 65 7d 0a 5c 70 70 72 | procedu|re}.\ppr|
|00004cf0| 6f 74 6f 7b 5c 68 62 6f | 78 20 74 6f 20 31 5c 77 |oto{\hbo|x to 1\w|
|00004d00| 64 30 20 7b 5c 68 66 69 | 6c 24 5c 76 64 6f 74 73 |d0 {\hfi|l$\vdots|
|00004d10| 24 5c 68 66 69 6c 7d 7d | 7b 5c 68 62 6f 78 20 74 |$\hfil}}|{\hbox t|
|00004d20| 6f 20 31 5c 77 64 31 20 | 7b 5c 68 66 69 6c 24 5c |o 1\wd1 |{\hfil$\|
|00004d30| 76 64 6f 74 73 24 5c 68 | 66 69 6c 7d 7d 0a 5c 70 |vdots$\h|fil}}.\p|
|00004d40| 72 6f 74 6f 7b 63 64 64 | 64 61 72 7d 7b 20 70 61 |roto{cdd|dar}{ pa|
|00004d50| 69 72 7d 7b 65 73 73 65 | 6e 74 69 61 6c 20 70 72 |ir}{esse|ntial pr|
|00004d60| 6f 63 65 64 75 72 65 7d | 0a 5c 70 72 6f 74 6f 7b |ocedure}|.\proto{|
|00004d70| 63 64 64 64 64 72 7d 7b | 20 70 61 69 72 7d 7b 65 |cddddr}{| pair}{e|
|00004d80| 73 73 65 6e 74 69 61 6c | 20 70 72 6f 63 65 64 75 |ssential| procedu|
|00004d90| 72 65 7d 7d 0a 0a 54 68 | 65 73 65 20 70 72 6f 63 |re}}..Th|ese proc|
|00004da0| 65 64 75 72 65 73 20 61 | 72 65 20 63 6f 6d 70 6f |edures a|re compo|
|00004db0| 73 69 74 69 6f 6e 73 20 | 6f 66 20 5c 69 64 65 7b |sitions |of \ide{|
|00004dc0| 63 61 72 7d 20 61 6e 64 | 20 5c 69 64 65 7b 63 64 |car} and| \ide{cd|
|00004dd0| 72 7d 2c 20 77 68 65 72 | 65 0a 66 6f 72 20 65 78 |r}, wher|e.for ex|
|00004de0| 61 6d 70 6c 65 20 5c 69 | 64 65 7b 63 61 64 64 72 |ample \i|de{caddr|
|00004df0| 7d 20 63 6f 75 6c 64 20 | 62 65 20 64 65 66 69 6e |} could |be defin|
|00004e00| 65 64 20 62 79 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |ed by..\|begin{sc|
|00004e10| 68 65 6d 65 7d 0a 28 64 | 65 66 69 6e 65 20 63 61 |heme}.(d|efine ca|
|00004e20| 64 64 72 20 28 6c 61 6d | 62 64 61 20 28 78 29 20 |ddr (lam|bda (x) |
|00004e30| 28 63 61 72 20 28 63 64 | 72 20 28 63 64 72 20 78 |(car (cd|r (cdr x|
|00004e40| 29 29 29 29 29 7b 5c 72 | 6d 2e 7d 25 0a 5c 65 6e |))))){\r|m.}%.\en|
|00004e50| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 41 72 62 69 74 |d{scheme|}..Arbit|
|00004e60| 72 61 72 79 20 63 6f 6d | 70 6f 73 69 74 69 6f 6e |rary com|position|
|00004e70| 73 2c 20 75 70 20 74 6f | 20 66 6f 75 72 20 64 65 |s, up to| four de|
|00004e80| 65 70 2c 20 61 72 65 20 | 70 72 6f 76 69 64 65 64 |ep, are |provided|
|00004e90| 2e 20 20 54 68 65 72 65 | 20 61 72 65 0a 74 77 65 |. There| are.twe|
|00004ea0| 6e 74 79 2d 65 69 67 68 | 74 20 6f 66 20 74 68 65 |nty-eigh|t of the|
|00004eb0| 73 65 20 70 72 6f 63 65 | 64 75 72 65 73 20 69 6e |se proce|dures in|
|00004ec0| 20 61 6c 6c 2e 0a 0a 5c | 65 6e 64 7b 65 6e 74 72 | all...\|end{entr|
|00004ed0| 79 7d 0a 0a 0a 5c 62 65 | 67 69 6e 7b 65 6e 74 72 |y}...\be|gin{entr|
|00004ee0| 79 7d 7b 25 0a 5c 70 72 | 6f 74 6f 7b 6e 75 6c 6c |y}{%.\pr|oto{null|
|00004ef0| 3f 7d 7b 20 6f 62 6a 7d | 7b 65 73 73 65 6e 74 69 |?}{ obj}|{essenti|
|00004f00| 61 6c 20 70 72 6f 63 65 | 64 75 72 65 7d 7d 0a 0a |al proce|dure}}..|
|00004f10| 52 65 74 75 72 6e 73 20 | 5c 73 63 68 74 72 75 65 |Returns |\schtrue|
|00004f20| 7b 7d 20 69 66 20 5c 76 | 61 72 7b 6f 62 6a 7d 20 |{} if \v|ar{obj} |
|00004f30| 69 73 20 74 68 65 20 65 | 6d 70 74 79 20 6c 69 73 |is the e|mpty lis|
|00004f40| 74 5c 69 6e 64 65 78 7b | 65 6d 70 74 79 20 6c 69 |t\index{|empty li|
|00004f50| 73 74 7d 2c 0a 6f 74 68 | 65 72 77 69 73 65 20 72 |st},.oth|erwise r|
|00004f60| 65 74 75 72 6e 73 20 5c | 73 63 68 66 61 6c 73 65 |eturns \|schfalse|
|00004f70| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 6e 6f 74 65 7d 0a |...\begi|n{note}.|
|00004f80| 49 6e 20 69 6d 70 6c 65 | 6d 65 6e 74 61 74 69 6f |In imple|mentatio|
|00004f90| 6e 73 20 69 6e 20 77 68 | 69 63 68 20 74 68 65 20 |ns in wh|ich the |
|00004fa0| 65 6d 70 74 79 0a 6c 69 | 73 74 20 69 73 20 74 68 |empty.li|st is th|
|00004fb0| 65 20 73 61 6d 65 20 61 | 73 20 5c 73 63 68 66 61 |e same a|s \schfa|
|00004fc0| 6c 73 65 7b 7d 2c 20 5c | 69 64 65 7b 6e 75 6c 6c |lse{}, \|ide{null|
|00004fd0| 3f 7d 20 77 69 6c 6c 20 | 72 65 74 75 72 6e 20 5c |?} will |return \|
|00004fe0| 73 63 68 74 72 75 65 7b | 7d 0a 69 66 20 5c 76 61 |schtrue{|}.if \va|
|00004ff0| 72 7b 6f 62 6a 7d 20 69 | 73 20 5c 73 63 68 66 61 |r{obj} i|s \schfa|
|00005000| 6c 73 65 7b 7d 2e 0a 5c | 65 6e 64 7b 6e 6f 74 65 |lse{}..\|end{note|
|00005010| 7d 0a 20 0a 5c 65 6e 64 | 7b 65 6e 74 72 79 7d 0a |}. .\end|{entry}.|
|00005020| 0a 5c 62 65 67 69 6e 7b | 65 6e 74 72 79 7d 7b 25 |.\begin{|entry}{%|
|00005030| 0a 5c 70 72 6f 74 6f 7b | 6c 69 73 74 3f 7d 7b 20 |.\proto{|list?}{ |
|00005040| 6f 62 6a 7d 7b 65 73 73 | 65 6e 74 69 61 6c 20 70 |obj}{ess|ential p|
|00005050| 72 6f 63 65 64 75 72 65 | 7d 7d 0a 0a 52 65 74 75 |rocedure|}}..Retu|
|00005060| 72 6e 73 20 5c 73 63 68 | 74 72 75 65 7b 7d 20 69 |rns \sch|true{} i|
|00005070| 66 20 5c 76 61 72 7b 6f | 62 6a 7d 20 69 73 20 61 |f \var{o|bj} is a|
|00005080| 20 6c 69 73 74 2c 20 6f | 74 68 65 72 77 69 73 65 | list, o|therwise|
|00005090| 20 72 65 74 75 72 6e 73 | 20 5c 73 63 68 66 61 6c | returns| \schfal|
|000050a0| 73 65 7b 7d 2e 0a 42 79 | 20 64 65 66 69 6e 69 74 |se{}..By| definit|
|000050b0| 69 6f 6e 2c 20 61 6c 6c | 20 6c 69 73 74 73 20 68 |ion, all| lists h|
|000050c0| 61 76 65 20 66 69 6e 69 | 74 65 20 6c 65 6e 67 74 |ave fini|te lengt|
|000050d0| 68 20 61 6e 64 20 61 72 | 65 20 74 65 72 6d 69 6e |h and ar|e termin|
|000050e0| 61 74 65 64 20 62 79 0a | 74 68 65 20 65 6d 70 74 |ated by.|the empt|
|000050f0| 79 20 6c 69 73 74 2e 0a | 0a 5c 62 65 67 69 6e 7b |y list..|.\begin{|
|00005100| 73 63 68 65 6d 65 7d 0a | 20 20 20 20 20 20 20 20 |scheme}.| |
|00005110| 28 6c 69 73 74 20 27 28 | 61 20 62 20 63 29 29 20 |(list '(|a b c)) |
|00005120| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 74 72 | \ev| \schtr|
|00005130| 75 65 0a 20 20 20 20 20 | 20 20 20 28 6c 69 73 74 |ue. | (list|
|00005140| 20 27 28 29 29 20 20 20 | 20 20 20 20 20 20 20 20 | '()) | |
|00005150| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 20 20 |\ev \sc|htrue. |
|00005160| 20 20 20 20 20 20 28 6c | 69 73 74 20 27 28 61 20 | (l|ist '(a |
|00005170| 2e 20 62 29 29 20 20 20 | 20 20 20 5c 65 76 20 20 |. b)) | \ev |
|00005180| 5c 73 63 68 66 61 6c 73 | 65 0a 20 20 20 20 20 20 |\schfals|e. |
|00005190| 20 20 28 6c 65 74 20 28 | 28 78 20 28 6c 69 73 74 | (let (|(x (list|
|000051a0| 20 27 61 29 29 29 0a 20 | 20 20 20 20 20 20 20 20 | 'a))). | |
|000051b0| 20 28 73 65 74 2d 63 64 | 72 21 20 78 20 78 29 0a | (set-cd|r! x x).|
|000051c0| 20 20 20 20 20 20 20 20 | 20 20 28 6c 69 73 74 3f | | (list?|
|000051d0| 20 78 29 29 20 20 20 20 | 20 20 20 20 20 5c 65 76 | x)) | \ev|
|000051e0| 20 20 5c 73 63 68 66 61 | 6c 73 65 25 0a 5c 65 6e | \schfa|lse%.\en|
|000051f0| 64 7b 73 63 68 65 6d 65 | 7d 0a 5c 65 6e 64 7b 65 |d{scheme|}.\end{e|
|00005200| 6e 74 72 79 7d 0a 0a 0a | 5c 62 65 67 69 6e 7b 65 |ntry}...|\begin{e|
|00005210| 6e 74 72 79 7d 7b 25 0a | 5c 70 72 6f 74 6f 7b 6c |ntry}{%.|\proto{l|
|00005220| 69 73 74 7d 7b 20 5c 76 | 61 72 7b 6f 62 6a 7d 20 |ist}{ \v|ar{obj} |
|00005230| 5c 64 6f 74 73 66 6f 6f | 7d 7b 65 73 73 65 6e 74 |\dotsfoo|}{essent|
|00005240| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00005250| 0a 52 65 74 75 72 6e 73 | 20 61 20 6c 69 73 74 20 |.Returns| a list |
|00005260| 6f 66 20 69 74 73 20 61 | 72 67 75 6d 65 6e 74 73 |of its a|rguments|
|00005270| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |...\begi|n{scheme|
|00005280| 7d 0a 28 6c 69 73 74 20 | 27 61 20 28 2b 20 33 20 |}.(list |'a (+ 3 |
|00005290| 34 29 20 27 63 29 20 20 | 20 20 20 20 20 20 20 20 |4) 'c) | |
|000052a0| 20 20 5c 65 76 20 20 28 | 61 20 37 20 63 29 0a 28 | \ev (|a 7 c).(|
|000052b0| 6c 69 73 74 29 20 20 20 | 20 20 20 20 20 20 20 20 |list) | |
|000052c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c | | \|
|000052d0| 65 76 20 20 28 29 25 0a | 5c 65 6e 64 7b 73 63 68 |ev ()%.|\end{sch|
|000052e0| 65 6d 65 7d 0a 5c 65 6e | 64 7b 65 6e 74 72 79 7d |eme}.\en|d{entry}|
|000052f0| 0a 0a 0a 5c 62 65 67 69 | 6e 7b 65 6e 74 72 79 7d |...\begi|n{entry}|
|00005300| 7b 25 0a 5c 70 72 6f 74 | 6f 7b 6c 65 6e 67 74 68 |{%.\prot|o{length|
|00005310| 7d 7b 20 6c 69 73 74 7d | 7b 65 73 73 65 6e 74 69 |}{ list}|{essenti|
|00005320| 61 6c 20 70 72 6f 63 65 | 64 75 72 65 7d 7d 0a 0a |al proce|dure}}..|
|00005330| 5c 6e 6f 64 6f 6d 61 69 | 6e 7b 5c 76 61 72 7b 4c |\nodomai|n{\var{L|
|00005340| 69 73 74 7d 20 6d 75 73 | 74 20 62 65 20 61 20 6c |ist} mus|t be a l|
|00005350| 69 73 74 2e 7d 0a 52 65 | 74 75 72 6e 73 20 74 68 |ist.}.Re|turns th|
|00005360| 65 20 6c 65 6e 67 74 68 | 20 6f 66 20 5c 76 61 72 |e length| of \var|
|00005370| 7b 6c 69 73 74 7d 2e 0a | 0a 5c 62 65 67 69 6e 7b |{list}..|.\begin{|
|00005380| 73 63 68 65 6d 65 7d 0a | 28 6c 65 6e 67 74 68 20 |scheme}.|(length |
|00005390| 27 28 61 20 62 20 63 29 | 29 20 20 20 20 20 20 20 |'(a b c)|) |
|000053a0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 33 0a 28 | |\ev 3.(|
|000053b0| 6c 65 6e 67 74 68 20 27 | 28 61 20 28 62 29 20 28 |length '|(a (b) (|
|000053c0| 63 20 64 20 65 29 29 29 | 20 20 20 20 20 20 20 5c |c d e)))| \|
|000053d0| 65 76 20 20 33 0a 28 6c | 65 6e 67 74 68 20 27 28 |ev 3.(l|ength '(|
|000053e0| 29 29 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |)) | |
|000053f0| 20 20 20 20 20 20 5c 65 | 76 20 20 30 25 0a 5c 65 | \e|v 0%.\e|
|00005400| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 5c 65 6e 64 7b |nd{schem|e}.\end{|
|00005410| 65 6e 74 72 79 7d 0a 0a | 0a 5c 62 65 67 69 6e 7b |entry}..|.\begin{|
|00005420| 65 6e 74 72 79 7d 7b 25 | 0a 5c 70 72 6f 74 6f 7b |entry}{%|.\proto{|
|00005430| 61 70 70 65 6e 64 7d 7b | 20 6c 69 73 74 20 5c 64 |append}{| list \d|
|00005440| 6f 74 73 66 6f 6f 7d 7b | 65 73 73 65 6e 74 69 61 |otsfoo}{|essentia|
|00005450| 6c 20 70 72 6f 63 65 64 | 75 72 65 7d 7d 0a 0a 5c |l proced|ure}}..\|
|00005460| 6e 6f 64 6f 6d 61 69 6e | 7b 41 6c 6c 20 5c 76 61 |nodomain|{All \va|
|00005470| 72 7b 6c 69 73 74 7d 73 | 20 73 68 6f 75 6c 64 20 |r{list}s| should |
|00005480| 62 65 20 6c 69 73 74 73 | 2e 7d 0a 52 65 74 75 72 |be lists|.}.Retur|
|00005490| 6e 73 20 61 20 6c 69 73 | 74 20 63 6f 6e 73 69 73 |ns a lis|t consis|
|000054a0| 74 69 6e 67 20 6f 66 20 | 74 68 65 20 65 6c 65 6d |ting of |the elem|
|000054b0| 65 6e 74 73 20 6f 66 20 | 74 68 65 20 66 69 72 73 |ents of |the firs|
|000054c0| 74 20 5c 76 61 72 7b 6c | 69 73 74 7d 0a 66 6f 6c |t \var{l|ist}.fol|
|000054d0| 6c 6f 77 65 64 20 62 79 | 20 74 68 65 20 65 6c 65 |lowed by| the ele|
|000054e0| 6d 65 6e 74 73 20 6f 66 | 20 74 68 65 20 6f 74 68 |ments of| the oth|
|000054f0| 65 72 20 5c 76 61 72 7b | 6c 69 73 74 7d 73 2e 0a |er \var{|list}s..|
|00005500| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00005510| 28 61 70 70 65 6e 64 20 | 27 28 78 29 20 27 28 79 |(append |'(x) '(y|
|00005520| 29 29 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |)) | |
|00005530| 5c 65 76 20 20 28 78 20 | 79 29 0a 28 61 70 70 65 |\ev (x |y).(appe|
|00005540| 6e 64 20 27 28 61 29 20 | 27 28 62 20 63 20 64 29 |nd '(a) |'(b c d)|
|00005550| 29 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 |) | \ev |
|00005560| 28 61 20 62 20 63 20 64 | 29 0a 28 61 70 70 65 6e |(a b c d|).(appen|
|00005570| 64 20 27 28 61 20 28 62 | 29 29 20 27 28 28 63 29 |d '(a (b|)) '((c)|
|00005580| 29 29 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 28 |)) | \ev (|
|00005590| 61 20 28 62 29 20 28 63 | 29 29 25 0a 5c 65 6e 64 |a (b) (c|))%.\end|
|000055a0| 7b 73 63 68 65 6d 65 7d | 0a 0a 54 68 65 20 72 65 |{scheme}|..The re|
|000055b0| 73 75 6c 74 69 6e 67 20 | 6c 69 73 74 20 69 73 20 |sulting |list is |
|000055c0| 61 6c 77 61 79 73 20 6e | 65 77 6c 79 20 61 6c 6c |always n|ewly all|
|000055d0| 6f 63 61 74 65 64 2c 20 | 65 78 63 65 70 74 20 74 |ocated, |except t|
|000055e0| 68 61 74 20 69 74 20 73 | 68 61 72 65 73 0a 73 74 |hat it s|hares.st|
|000055f0| 72 75 63 74 75 72 65 20 | 77 69 74 68 20 74 68 65 |ructure |with the|
|00005600| 20 6c 61 73 74 20 5c 76 | 61 72 7b 6c 69 73 74 7d | last \v|ar{list}|
|00005610| 20 61 72 67 75 6d 65 6e | 74 2e 20 20 54 68 65 20 | argumen|t. The |
|00005620| 6c 61 73 74 20 61 72 67 | 75 6d 65 6e 74 20 6d 61 |last arg|ument ma|
|00005630| 79 0a 61 63 74 75 61 6c | 6c 79 20 62 65 20 61 6e |y.actual|ly be an|
|00005640| 79 20 6f 62 6a 65 63 74 | 3b 20 61 6e 20 69 6d 70 |y object|; an imp|
|00005650| 72 6f 70 65 72 20 6c 69 | 73 74 20 72 65 73 75 6c |roper li|st resul|
|00005660| 74 73 20 69 66 20 74 68 | 65 20 6c 61 73 74 20 61 |ts if th|e last a|
|00005670| 72 67 75 6d 65 6e 74 20 | 69 73 20 6e 6f 74 20 61 |rgument |is not a|
|00005680| 0a 70 72 6f 70 65 72 20 | 6c 69 73 74 2e 20 20 5c |.proper |list. \|
|00005690| 74 6f 64 6f 7b 54 68 69 | 73 20 69 73 20 70 72 65 |todo{Thi|s is pre|
|000056a0| 74 74 79 20 61 77 6b 77 | 61 72 64 2e 20 20 49 20 |tty awkw|ard. I |
|000056b0| 73 68 6f 75 6c 64 20 67 | 65 74 20 42 61 72 74 6c |should g|et Bartl|
|000056c0| 65 79 20 74 6f 20 66 69 | 78 20 74 68 69 73 2e 7d |ey to fi|x this.}|
|000056d0| 0a 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |..\begin|{scheme}|
|000056e0| 0a 28 61 70 70 65 6e 64 | 20 27 28 61 20 62 29 20 |.(append| '(a b) |
|000056f0| 27 28 63 20 2e 20 64 29 | 29 20 20 20 20 20 20 20 |'(c . d)|) |
|00005700| 20 5c 65 76 20 20 28 61 | 20 62 20 63 20 2e 20 64 | \ev (a| b c . d|
|00005710| 29 0a 28 61 70 70 65 6e | 64 20 27 28 29 20 27 61 |).(appen|d '() 'a|
|00005720| 29 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |) | |
|00005730| 20 20 5c 65 76 20 20 61 | 25 0a 5c 65 6e 64 7b 73 | \ev a|%.\end{s|
|00005740| 63 68 65 6d 65 7d 0a 5c | 65 6e 64 7b 65 6e 74 72 |cheme}.\|end{entr|
|00005750| 79 7d 0a 0a 0a 5c 62 65 | 67 69 6e 7b 65 6e 74 72 |y}...\be|gin{entr|
|00005760| 79 7d 7b 25 0a 5c 70 72 | 6f 74 6f 7b 72 65 76 65 |y}{%.\pr|oto{reve|
|00005770| 72 73 65 7d 7b 20 6c 69 | 73 74 7d 7b 65 73 73 65 |rse}{ li|st}{esse|
|00005780| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00005790| 7d 0a 0a 5c 6e 6f 64 6f | 6d 61 69 6e 7b 5c 76 61 |}..\nodo|main{\va|
|000057a0| 72 7b 4c 69 73 74 7d 20 | 6d 75 73 74 20 62 65 20 |r{List} |must be |
|000057b0| 61 20 6c 69 73 74 2e 7d | 0a 52 65 74 75 72 6e 73 |a list.}|.Returns|
|000057c0| 20 61 20 6e 65 77 6c 79 | 20 61 6c 6c 6f 63 61 74 | a newly| allocat|
|000057d0| 65 64 20 6c 69 73 74 20 | 63 6f 6e 73 69 73 74 69 |ed list |consisti|
|000057e0| 6e 67 20 6f 66 20 74 68 | 65 20 65 6c 65 6d 65 6e |ng of th|e elemen|
|000057f0| 74 73 20 6f 66 20 5c 76 | 61 72 7b 6c 69 73 74 7d |ts of \v|ar{list}|
|00005800| 0a 69 6e 20 72 65 76 65 | 72 73 65 20 6f 72 64 65 |.in reve|rse orde|
|00005810| 72 2e 0a 0a 5c 62 65 67 | 69 6e 7b 73 63 68 65 6d |r...\beg|in{schem|
|00005820| 65 7d 0a 28 72 65 76 65 | 72 73 65 20 27 28 61 20 |e}.(reve|rse '(a |
|00005830| 62 20 63 29 29 20 20 20 | 20 20 20 20 20 20 20 20 |b c)) | |
|00005840| 20 20 20 5c 65 76 20 20 | 28 63 20 62 20 61 29 0a | \ev |(c b a).|
|00005850| 28 72 65 76 65 72 73 65 | 20 27 28 61 20 28 62 20 |(reverse| '(a (b |
|00005860| 63 29 20 64 20 28 65 20 | 28 66 29 29 29 29 20 20 |c) d (e |(f)))) |
|00005870| 5c 6c 65 76 20 20 28 28 | 65 20 28 66 29 29 20 64 |\lev ((|e (f)) d|
|00005880| 20 28 62 20 63 29 20 61 | 29 25 0a 5c 65 6e 64 7b | (b c) a|)%.\end{|
|00005890| 73 63 68 65 6d 65 7d 0a | 5c 65 6e 64 7b 65 6e 74 |scheme}.|\end{ent|
|000058a0| 72 79 7d 0a 0a 0a 5c 62 | 65 67 69 6e 7b 65 6e 74 |ry}...\b|egin{ent|
|000058b0| 72 79 7d 7b 25 0a 5c 70 | 72 6f 74 6f 7b 6c 69 73 |ry}{%.\p|roto{lis|
|000058c0| 74 2d 74 61 69 6c 7d 7b | 20 6c 69 73 74 20 5c 76 |t-tail}{| list \v|
|000058d0| 72 7b 6b 7d 7d 7b 70 72 | 6f 63 65 64 75 72 65 7d |r{k}}{pr|ocedure}|
|000058e0| 7d 0a 0a 52 65 74 75 72 | 6e 73 20 74 68 65 20 73 |}..Retur|ns the s|
|000058f0| 75 62 6c 69 73 74 20 6f | 66 20 5c 76 61 72 7b 6c |ublist o|f \var{l|
|00005900| 69 73 74 7d 20 6f 62 74 | 61 69 6e 65 64 20 62 79 |ist} obt|ained by|
|00005910| 20 6f 6d 69 74 74 69 6e | 67 20 74 68 65 20 66 69 | omittin|g the fi|
|00005920| 72 73 74 20 5c 76 72 7b | 6b 7d 0a 65 6c 65 6d 65 |rst \vr{|k}.eleme|
|00005930| 6e 74 73 2e 0a 5c 69 64 | 65 7b 4c 69 73 74 2d 74 |nts..\id|e{List-t|
|00005940| 61 69 6c 7d 20 63 6f 75 | 6c 64 20 62 65 20 64 65 |ail} cou|ld be de|
|00005950| 66 69 6e 65 64 20 62 79 | 0a 0a 5c 62 65 67 69 6e |fined by|..\begin|
|00005960| 7b 73 63 68 65 6d 65 7d | 0a 28 64 65 66 69 6e 65 |{scheme}|.(define|
|00005970| 20 6c 69 73 74 2d 74 61 | 69 6c 0a 20 20 28 6c 61 | list-ta|il. (la|
|00005980| 6d 62 64 61 20 28 78 20 | 6b 29 0a 20 20 20 20 28 |mbda (x |k). (|
|00005990| 69 66 20 28 7a 65 72 6f | 3f 20 6b 29 0a 20 20 20 |if (zero|? k). |
|000059a0| 20 20 20 20 20 78 0a 20 | 20 20 20 20 20 20 20 28 | x. | (|
|000059b0| 6c 69 73 74 2d 74 61 69 | 6c 20 28 63 64 72 20 78 |list-tai|l (cdr x|
|000059c0| 29 20 28 2d 20 6b 20 31 | 29 29 29 29 29 25 0a 5c |) (- k 1|)))))%.\|
|000059d0| 65 6e 64 7b 73 63 68 65 | 6d 65 7d 20 0a 5c 65 6e |end{sche|me} .\en|
|000059e0| 64 7b 65 6e 74 72 79 7d | 0a 0a 0a 5c 62 65 67 69 |d{entry}|...\begi|
|000059f0| 6e 7b 65 6e 74 72 79 7d | 7b 25 0a 5c 70 72 6f 74 |n{entry}|{%.\prot|
|00005a00| 6f 7b 6c 69 73 74 2d 72 | 65 66 7d 7b 20 6c 69 73 |o{list-r|ef}{ lis|
|00005a10| 74 20 5c 76 72 7b 6b 7d | 7d 7b 65 73 73 65 6e 74 |t \vr{k}|}{essent|
|00005a20| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00005a30| 0a 52 65 74 75 72 6e 73 | 20 74 68 65 20 5c 76 72 |.Returns| the \vr|
|00005a40| 7b 6b 7d 74 68 20 65 6c | 65 6d 65 6e 74 20 6f 66 |{k}th el|ement of|
|00005a50| 20 5c 76 61 72 7b 6c 69 | 73 74 7d 2e 20 20 28 54 | \var{li|st}. (T|
|00005a60| 68 69 73 20 69 73 20 74 | 68 65 20 73 61 6d 65 0a |his is t|he same.|
|00005a70| 61 73 20 74 68 65 20 63 | 61 72 20 6f 66 20 7b 5c |as the c|ar of {\|
|00005a80| 74 74 28 6c 69 73 74 2d | 74 61 69 6c 20 5c 76 61 |tt(list-|tail \va|
|00005a90| 72 7b 6c 69 73 74 7d 20 | 5c 76 72 7b 6b 7d 29 7d |r{list} |\vr{k})}|
|00005aa0| 2e 29 0a 0a 5c 62 65 67 | 69 6e 7b 73 63 68 65 6d |.)..\beg|in{schem|
|00005ab0| 65 7d 0a 28 6c 69 73 74 | 2d 72 65 66 20 27 28 61 |e}.(list|-ref '(a|
|00005ac0| 20 62 20 63 20 64 29 20 | 32 29 20 20 20 20 20 20 | b c d) |2) |
|00005ad0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|00005ae0| 63 0a 28 6c 69 73 74 2d | 72 65 66 20 27 28 61 20 |c.(list-|ref '(a |
|00005af0| 62 20 63 20 64 29 0a 20 | 20 20 20 20 20 20 20 20 |b c d). | |
|00005b00| 20 28 69 6e 65 78 61 63 | 74 2d 3e 65 78 61 63 74 | (inexac|t->exact|
|00005b10| 20 28 72 6f 75 6e 64 20 | 31 2e 38 29 29 29 20 5c | (round |1.8))) \|
|00005b20| 6c 65 76 20 20 63 25 0a | 5c 65 6e 64 7b 73 63 68 |lev c%.|\end{sch|
|00005b30| 65 6d 65 7d 0a 5c 65 6e | 64 7b 65 6e 74 72 79 7d |eme}.\en|d{entry}|
|00005b40| 0a 0a 0a 25 5c 62 65 67 | 69 6e 7b 65 6e 74 72 79 |...%\beg|in{entry|
|00005b50| 7d 7b 25 0a 25 5c 70 72 | 6f 74 6f 7b 6c 61 73 74 |}{%.%\pr|oto{last|
|00005b60| 2d 70 61 69 72 7d 7b 20 | 6c 69 73 74 7d 7b 70 72 |-pair}{ |list}{pr|
|00005b70| 6f 63 65 64 75 72 65 7d | 7d 0a 25 0a 25 52 65 74 |ocedure}|}.%.%Ret|
|00005b80| 75 72 6e 73 20 74 68 65 | 20 6c 61 73 74 20 70 61 |urns the| last pa|
|00005b90| 69 72 20 69 6e 20 74 68 | 65 20 6e 6f 6e 65 6d 70 |ir in th|e nonemp|
|00005ba0| 74 79 2c 20 70 6f 73 73 | 69 62 6c 79 20 69 6d 70 |ty, poss|ibly imp|
|00005bb0| 72 6f 70 65 72 2c 20 6c | 69 73 74 20 5c 76 61 72 |roper, l|ist \var|
|00005bc0| 7b 6c 69 73 74 7d 2e 0a | 25 5c 69 64 65 7b 4c 61 |{list}..|%\ide{La|
|00005bd0| 73 74 2d 70 61 69 72 7d | 20 63 6f 75 6c 64 20 62 |st-pair}| could b|
|00005be0| 65 20 64 65 66 69 6e 65 | 64 20 62 79 0a 25 0a 25 |e define|d by.%.%|
|00005bf0| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 25 |\begin{s|cheme}.%|
|00005c00| 28 64 65 66 69 6e 65 20 | 6c 61 73 74 2d 70 61 69 |(define |last-pai|
|00005c10| 72 0a 25 20 20 28 6c 61 | 6d 62 64 61 20 28 78 29 |r.% (la|mbda (x)|
|00005c20| 0a 25 20 20 20 20 28 69 | 66 20 28 70 61 69 72 3f |.% (i|f (pair?|
|00005c30| 20 28 63 64 72 20 78 29 | 29 0a 25 20 20 20 20 20 | (cdr x)|).% |
|00005c40| 20 20 20 28 6c 61 73 74 | 2d 70 61 69 72 20 28 63 | (last|-pair (c|
|00005c50| 64 72 20 78 29 29 0a 25 | 20 20 20 20 20 20 20 20 |dr x)).%| |
|00005c60| 78 29 29 29 25 0a 25 5c | 65 6e 64 7b 73 63 68 65 |x)))%.%\|end{sche|
|00005c70| 6d 65 7d 20 0a 25 20 0a | 25 5c 65 6e 64 7b 65 6e |me} .% .|%\end{en|
|00005c80| 74 72 79 7d 0a 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |try}...\|begin{en|
|00005c90| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 6d 65 |try}{%.\|proto{me|
|00005ca0| 6d 71 7d 7b 20 6f 62 6a | 20 6c 69 73 74 7d 7b 65 |mq}{ obj| list}{e|
|00005cb0| 73 73 65 6e 74 69 61 6c | 20 70 72 6f 63 65 64 75 |ssential| procedu|
|00005cc0| 72 65 7d 0a 5c 70 72 6f | 74 6f 7b 6d 65 6d 76 7d |re}.\pro|to{memv}|
|00005cd0| 7b 20 6f 62 6a 20 6c 69 | 73 74 7d 7b 65 73 73 65 |{ obj li|st}{esse|
|00005ce0| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00005cf0| 0a 5c 70 72 6f 74 6f 7b | 6d 65 6d 62 65 72 7d 7b |.\proto{|member}{|
|00005d00| 20 6f 62 6a 20 6c 69 73 | 74 7d 7b 65 73 73 65 6e | obj lis|t}{essen|
|00005d10| 74 69 61 6c 20 70 72 6f | 63 65 64 75 72 65 7d 7d |tial pro|cedure}}|
|00005d20| 0a 0a 54 68 65 73 65 20 | 70 72 6f 63 65 64 75 72 |..These |procedur|
|00005d30| 65 73 20 72 65 74 75 72 | 6e 20 74 68 65 20 66 69 |es retur|n the fi|
|00005d40| 72 73 74 20 73 75 62 6c | 69 73 74 20 6f 66 20 5c |rst subl|ist of \|
|00005d50| 76 61 72 7b 6c 69 73 74 | 7d 20 77 68 6f 73 65 20 |var{list|} whose |
|00005d60| 63 61 72 20 69 73 0a 5c | 76 61 72 7b 6f 62 6a 7d |car is.\|var{obj}|
|00005d70| 2c 20 77 68 65 72 65 20 | 74 68 65 20 73 75 62 6c |, where |the subl|
|00005d80| 69 73 74 73 20 6f 66 20 | 5c 76 61 72 7b 6c 69 73 |ists of |\var{lis|
|00005d90| 74 7d 20 61 72 65 20 74 | 68 65 20 6e 6f 6e 2d 65 |t} are t|he non-e|
|00005da0| 6d 70 74 79 20 6c 69 73 | 74 73 0a 72 65 74 75 72 |mpty lis|ts.retur|
|00005db0| 6e 65 64 20 62 79 20 7b | 5c 74 74 20 28 6c 69 73 |ned by {|\tt (lis|
|00005dc0| 74 2d 74 61 69 6c 20 5c | 76 61 72 7b 6c 69 73 74 |t-tail \|var{list|
|00005dd0| 7d 20 5c 76 61 72 7b 6b | 7d 29 7d 20 66 6f 72 20 |} \var{k|})} for |
|00005de0| 5c 76 61 72 7b 6b 7d 20 | 6c 65 73 73 0a 74 68 61 |\var{k} |less.tha|
|00005df0| 6e 20 74 68 65 20 6c 65 | 6e 67 74 68 20 6f 66 20 |n the le|ngth of |
|00005e00| 5c 76 61 72 7b 6c 69 73 | 74 7d 2e 20 20 49 66 0a |\var{lis|t}. If.|
|00005e10| 5c 76 61 72 7b 6f 62 6a | 7d 20 64 6f 65 73 20 6e |\var{obj|} does n|
|00005e20| 6f 74 20 6f 63 63 75 72 | 20 69 6e 20 5c 76 61 72 |ot occur| in \var|
|00005e30| 7b 6c 69 73 74 7d 2c 20 | 5c 73 63 68 66 61 6c 73 |{list}, |\schfals|
|00005e40| 65 7b 7d 20 28 6e 2e 62 | 2e 3a 7e 6e 6f 74 20 74 |e{} (n.b|.:~not t|
|00005e50| 68 65 20 65 6d 70 74 79 | 20 6c 69 73 74 29 20 69 |he empty| list) i|
|00005e60| 73 0a 72 65 74 75 72 6e | 65 64 2e 20 20 5c 69 64 |s.return|ed. \id|
|00005e70| 65 7b 4d 65 6d 71 7d 20 | 75 73 65 73 20 5c 69 64 |e{Memq} |uses \id|
|00005e80| 65 7b 65 71 3f 7d 5c 20 | 74 6f 20 63 6f 6d 70 61 |e{eq?}\ |to compa|
|00005e90| 72 65 20 5c 76 61 72 7b | 6f 62 6a 7d 20 77 69 74 |re \var{|obj} wit|
|00005ea0| 68 20 74 68 65 20 65 6c | 65 6d 65 6e 74 73 20 6f |h the el|ements o|
|00005eb0| 66 0a 5c 76 61 72 7b 6c | 69 73 74 7d 2c 20 77 68 |f.\var{l|ist}, wh|
|00005ec0| 69 6c 65 20 5c 69 64 65 | 7b 6d 65 6d 76 7d 20 75 |ile \ide|{memv} u|
|00005ed0| 73 65 73 20 5c 69 64 65 | 7b 65 71 76 3f 7d 5c 20 |ses \ide|{eqv?}\ |
|00005ee0| 61 6e 64 20 5c 69 64 65 | 7b 6d 65 6d 62 65 72 7d |and \ide|{member}|
|00005ef0| 20 75 73 65 73 20 5c 69 | 64 65 7b 65 71 75 61 6c | uses \i|de{equal|
|00005f00| 3f 7d 2e 0a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |?}...\be|gin{sche|
|00005f10| 6d 65 7d 0a 28 6d 65 6d | 71 20 27 61 20 27 28 61 |me}.(mem|q 'a '(a|
|00005f20| 20 62 20 63 29 29 20 20 | 20 20 20 20 20 20 20 20 | b c)) | |
|00005f30| 20 20 20 20 5c 65 76 20 | 20 28 61 20 62 20 63 29 | \ev | (a b c)|
|00005f40| 0a 28 6d 65 6d 71 20 27 | 62 20 27 28 61 20 62 20 |.(memq '|b '(a b |
|00005f50| 63 29 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |c)) | |
|00005f60| 20 5c 65 76 20 20 28 62 | 20 63 29 0a 28 6d 65 6d | \ev (b| c).(mem|
|00005f70| 71 20 27 61 20 27 28 62 | 20 63 20 64 29 29 20 20 |q 'a '(b| c d)) |
|00005f80| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00005f90| 20 5c 73 63 68 66 61 6c | 73 65 0a 28 6d 65 6d 71 | \schfal|se.(memq|
|00005fa0| 20 28 6c 69 73 74 20 27 | 61 29 20 27 28 62 20 28 | (list '|a) '(b (|
|00005fb0| 61 29 20 63 29 29 20 20 | 20 20 20 5c 65 76 20 20 |a) c)) | \ev |
|00005fc0| 5c 73 63 68 66 61 6c 73 | 65 0a 28 6d 65 6d 62 65 |\schfals|e.(membe|
|00005fd0| 72 20 28 6c 69 73 74 20 | 27 61 29 0a 20 20 20 20 |r (list |'a). |
|00005fe0| 20 20 20 20 27 28 62 20 | 28 61 29 20 63 29 29 20 | '(b |(a) c)) |
|00005ff0| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00006000| 20 28 28 61 29 20 63 29 | 0a 28 6d 65 6d 71 20 31 | ((a) c)|.(memq 1|
|00006010| 30 31 20 27 28 31 30 30 | 20 31 30 31 20 31 30 32 |01 '(100| 101 102|
|00006020| 29 29 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 75 |)) | \ev \u|
|00006030| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 6d 65 6d 76 |nspecifi|ed.(memv|
|00006040| 20 31 30 31 20 27 28 31 | 30 30 20 31 30 31 20 31 | 101 '(1|00 101 1|
|00006050| 30 32 29 29 20 20 20 20 | 20 20 20 5c 65 76 20 20 |02)) | \ev |
|00006060| 28 31 30 31 20 31 30 32 | 29 25 0a 5c 65 6e 64 7b |(101 102|)%.\end{|
|00006070| 73 63 68 65 6d 65 7d 20 | 0a 20 0a 5c 65 6e 64 7b |scheme} |. .\end{|
|00006080| 65 6e 74 72 79 7d 0a 0a | 0a 5c 62 65 67 69 6e 7b |entry}..|.\begin{|
|00006090| 65 6e 74 72 79 7d 7b 25 | 0a 5c 70 72 6f 74 6f 7b |entry}{%|.\proto{|
|000060a0| 61 73 73 71 7d 7b 20 6f | 62 6a 20 61 6c 69 73 74 |assq}{ o|bj alist|
|000060b0| 7d 7b 65 73 73 65 6e 74 | 69 61 6c 20 70 72 6f 63 |}{essent|ial proc|
|000060c0| 65 64 75 72 65 7d 0a 5c | 70 72 6f 74 6f 7b 61 73 |edure}.\|proto{as|
|000060d0| 73 76 7d 7b 20 6f 62 6a | 20 61 6c 69 73 74 7d 7b |sv}{ obj| alist}{|
|000060e0| 65 73 73 65 6e 74 69 61 | 6c 20 70 72 6f 63 65 64 |essentia|l proced|
|000060f0| 75 72 65 7d 0a 5c 70 72 | 6f 74 6f 7b 61 73 73 6f |ure}.\pr|oto{asso|
|00006100| 63 7d 7b 20 6f 62 6a 20 | 61 6c 69 73 74 7d 7b 65 |c}{ obj |alist}{e|
|00006110| 73 73 65 6e 74 69 61 6c | 20 70 72 6f 63 65 64 75 |ssential| procedu|
|00006120| 72 65 7d 7d 0a 0a 5c 64 | 6f 6d 61 69 6e 7b 5c 76 |re}}..\d|omain{\v|
|00006130| 61 72 7b 41 6c 69 73 74 | 7d 20 28 66 6f 72 20 60 |ar{Alist|} (for `|
|00006140| 60 61 73 73 6f 63 69 61 | 74 69 6f 6e 20 6c 69 73 |`associa|tion lis|
|00006150| 74 27 27 29 20 6d 75 73 | 74 20 62 65 20 61 20 6c |t'') mus|t be a l|
|00006160| 69 73 74 20 6f 66 0a 70 | 61 69 72 73 2e 7d 20 20 |ist of.p|airs.} |
|00006170| 54 68 65 73 65 20 70 72 | 6f 63 65 64 75 72 65 73 |These pr|ocedures|
|00006180| 20 66 69 6e 64 20 74 68 | 65 20 66 69 72 73 74 20 | find th|e first |
|00006190| 70 61 69 72 20 69 6e 20 | 5c 76 61 72 7b 61 6c 69 |pair in |\var{ali|
|000061a0| 73 74 7d 20 77 68 6f 73 | 65 20 63 61 72 20 66 69 |st} whos|e car fi|
|000061b0| 65 6c 64 20 69 73 20 5c | 76 61 72 7b 6f 62 6a 7d |eld is \|var{obj}|
|000061c0| 2c 0a 61 6e 64 20 72 65 | 74 75 72 6e 73 20 74 68 |,.and re|turns th|
|000061d0| 61 74 20 70 61 69 72 2e | 20 20 49 66 20 6e 6f 20 |at pair.| If no |
|000061e0| 70 61 69 72 20 69 6e 20 | 5c 76 61 72 7b 61 6c 69 |pair in |\var{ali|
|000061f0| 73 74 7d 20 68 61 73 20 | 5c 76 61 72 7b 6f 62 6a |st} has |\var{obj|
|00006200| 7d 20 61 73 20 69 74 73 | 0a 63 61 72 2c 20 5c 73 |} as its|.car, \s|
|00006210| 63 68 66 61 6c 73 65 7b | 7d 20 69 73 20 72 65 74 |chfalse{|} is ret|
|00006220| 75 72 6e 65 64 2e 20 20 | 5c 69 64 65 7b 41 73 73 |urned. |\ide{Ass|
|00006230| 71 7d 20 75 73 65 73 20 | 5c 69 64 65 7b 65 71 3f |q} uses |\ide{eq?|
|00006240| 7d 5c 20 74 6f 20 63 6f | 6d 70 61 72 65 20 5c 76 |}\ to co|mpare \v|
|00006250| 61 72 7b 6f 62 6a 7d 0a | 77 69 74 68 20 74 68 65 |ar{obj}.|with the|
|00006260| 20 63 61 72 20 66 69 65 | 6c 64 73 20 6f 66 20 74 | car fie|lds of t|
|00006270| 68 65 20 70 61 69 72 73 | 20 69 6e 20 5c 76 61 72 |he pairs| in \var|
|00006280| 7b 61 6c 69 73 74 7d 2c | 20 77 68 69 6c 65 20 5c |{alist},| while \|
|00006290| 69 64 65 7b 61 73 73 76 | 7d 20 75 73 65 73 0a 5c |ide{assv|} uses.\|
|000062a0| 69 64 65 7b 65 71 76 3f | 7d 5c 20 61 6e 64 20 5c |ide{eqv?|}\ and \|
|000062b0| 69 64 65 7b 61 73 73 6f | 63 7d 20 75 73 65 73 20 |ide{asso|c} uses |
|000062c0| 5c 69 64 65 7b 65 71 75 | 61 6c 3f 7d 2e 0a 0a 5c |\ide{equ|al?}...\|
|000062d0| 62 65 67 69 6e 7b 73 63 | 68 65 6d 65 7d 0a 28 64 |begin{sc|heme}.(d|
|000062e0| 65 66 69 6e 65 20 65 20 | 27 28 28 61 20 31 29 20 |efine e |'((a 1) |
|000062f0| 28 62 20 32 29 20 28 63 | 20 33 29 29 29 0a 28 61 |(b 2) (c| 3))).(a|
|00006300| 73 73 71 20 27 61 20 65 | 29 20 20 20 20 20 5c 65 |ssq 'a e|) \e|
|00006310| 76 20 20 28 61 20 31 29 | 0a 28 61 73 73 71 20 27 |v (a 1)|.(assq '|
|00006320| 62 20 65 29 20 20 20 20 | 20 5c 65 76 20 20 28 62 |b e) | \ev (b|
|00006330| 20 32 29 0a 28 61 73 73 | 71 20 27 64 20 65 29 20 | 2).(ass|q 'd e) |
|00006340| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 66 61 6c | \ev | \schfal|
|00006350| 73 65 0a 28 61 73 73 71 | 20 28 6c 69 73 74 20 27 |se.(assq| (list '|
|00006360| 61 29 20 27 28 28 28 61 | 29 29 20 28 28 62 29 29 |a) '(((a|)) ((b))|
|00006370| 20 28 28 63 29 29 29 29 | 0a 20 20 20 20 20 20 20 | ((c))))|. |
|00006380| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 73 | | \ev \s|
|00006390| 63 68 66 61 6c 73 65 0a | 28 61 73 73 6f 63 20 28 |chfalse.|(assoc (|
|000063a0| 6c 69 73 74 20 27 61 29 | 20 27 28 28 28 61 29 29 |list 'a)| '(((a))|
|000063b0| 20 28 28 62 29 29 20 28 | 28 63 29 29 29 29 20 20 | ((b)) (|(c)))) |
|000063c0| 20 0a 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | . | |
|000063d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|000063e0| 20 20 28 28 61 29 29 0a | 28 61 73 73 71 20 35 20 | ((a)).|(assq 5 |
|000063f0| 27 28 28 32 20 33 29 20 | 28 35 20 37 29 20 28 31 |'((2 3) |(5 7) (1|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.