Scheme ( ) c1993, 1994, 1995, 1996 Hirotsugu Kakugawa : 739 1-4-1 ( ) e-mail: kakugawa@sehiroshima-uacjp
Copy Free \Scheme " 1996 3 13 1 Copy Free \Scheme " 2 (2a) (2b) (2c) 3 (3a) (The Internet) (3b) 4 5 6 (6a) (6b) (6c) (6d) Scheme 1 1993 6 2 1994 8 3 1995 9 31 1996 3 32 1996 8
1 1 11 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 2 12 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 13 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 7 131 : : : : : : : : : : : : : : : : : : : : : : : 8 132 : : : : : : : : : : : : : : : : : : : 9 133 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 12 14 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 14 2 Scheme 17 21 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 17 22 Scheme (NGSCM) : : : : : : : : : : : : : : : : : : : 19 23 Scheme : : : : : : : : : : : : : : : : : : : : : 20 231 Mule : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 20 232 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 21 24 Scheme : : : : : : : : : : : : : : : : : : : : : : : : : 21 241 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 22 242 : : : : : : : : : : : : : : : : : : : : 23 25 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 23 3 Scheme ( ) 25 31 - - : : : : : : : : : : : : : : : : : : : : : : : : : : : 25 32 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 27 33 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 29 34 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 31 35 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 36 36 ( 1) : : : : : : : : : : : : : : : : : : : : : : : : : : 38 361 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 38 362 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 40 1
2 363 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 47 37 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 50 38 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 53 39 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 57 391 let : : : : : : : : : : : : : : : : : : : : : : : : : : : 58 392 let* : : : : : : : : : : : : : : : : : : : : : : : : : : 59 310 ( 1) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 60 3101 if : : : : : : : : : : : : : : : : : : : : : : : : : : : 60 3102 cond : : : : : : : : : : : : : : : : : : : : : : : : : : 61 3103 begin : : : : : : : : : : : : : : : : : : : : : : : 63 3104 and or : : : : : : : : : : : : : : : : : : : : : 64 311 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 65 312 : : : : : : : : : : : : : : : : : : : : : : : 69 4 NGSCM 73 41 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 73 42 NGSCM : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 74 421 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 74 422 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 75 43 NGSCM : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 76 431 : : : : : : : : : : : : : : : : : : : : : : : 76 432 : : : : : : : : : : : : : : : : : : : : : 77 433 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 77 44 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 77 441 Mule : : : : : : : : : : : : : : : : : : : : : : : : : : : : 84 442 Scheme : : : : : : : : : : : : : : : : : : : : 85 5 87 51 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 89 511 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 89 512 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 93 52 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 98 53 1: : : : : : : : : : : : : : : : : : : : : : : 104 531 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 105 532 : : : : : : : : : : : : : 111 533 : : : : : : : : : : : : : : : : : : 112 534 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 114
6 Scheme ( ) 117 61 ( 2) : : : : : : : : : : : : : : : : : : : : : : : : : : 117 611 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 117 612 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 122 613 ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : 125 614 ( ) : : : : : : : : : : : : : : : : : : : : : : : : 130 62 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 132 621 : : : : : : : : : : : : : : : : : : : : : : : : : : 132 622 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 133 623 : : : : : : : : : : : : : : : : : : : : : 134 624 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 135 625 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 138 63 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 139 64 ( 2) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 143 641 case : : : : : : : : : : : : : : : : : : : : : : : : : : 143 642 let : : : : : : : : : : : : : : : : : : : : : 144 643 letrec : : : : : : : : : : : : : : : : : : : : : : : : 146 65 : : : : : : : : : : : : : : : : : : : : 148 651 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 148 652 : : : : : : : : : : : : : : : : : : : : : : : : : : 153 7 NGSCM 157 71 NGSCM : : : : : : : : : : : : : : : : : : : : : : : : : : : : 157 711 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 157 712 : : : : : : : : : : : : : : : : : : : : : : : : : 158 713 : : : : : : : : : : : : : : : : : : : : : : : : : : 160 714 : : : : : : : : : : : : : : : : : : : : : : : : : : 160 715 : : : : : : : : : : : : : : : : : : : : 163 716 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 164 717 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 165 718 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 168 719 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 170 8 Scheme 177 81 Scheme Scheme Interaction : : : : : : : : : : : : : : : : : 177 811 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 180 812 NGSCM Scheme : : : : : : : : : : : : : : : : : : : : 182 3
4 9 2 185 91 : : : : : : : : : : : : : : : : : : : : : : : : : : : 186 911 : : : : : : : : : : : : : : : : 186 912 : : : : : : : : : : : : : : : : : : : : : : : : 189 913 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 191 92 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 195 921 : : : : : : : : : : : : : : : : : : : : : : : : 195 922 : : : : : : : : : : : : : : : : : : : : : : : : : 198 923 : : : : : : : : : : : : : : : : : : : : : : : : : : 199 93 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 204 931 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 204 932 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 206 933 : : : : : : : : : : : : : : : : : : : : : 211 94 2: : : : : : : : : : : : : : : : : : : : : : : : 218 941 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 218 942 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 218 943 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 220 944 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 222 945 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 224 946 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 225 10 Scheme ( ) 229 101 ( 3) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 229 1011 do : : : : : : : : : : : : : : : : : : : : : : : : : 229 1012 for-each : : : : : : : : : : : : : : : : : : : : : 230 1013 map : : : : : : : : : : : : : : : : : : : : : : : : : : 232 1014 aplly : : : : : : : : : : : : : : : : : : : : : 233 102 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 234 1021 A : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 234 1022 : : : : : : : : : : : : : : : : : : : : : : : 235 1023 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 236 103 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 240 104 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 241 1041 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 242 1042 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 244
11 3 247 111 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 248 1111 : : : : : : : : : : : : : : : : : : : 248 1112 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 249 1113 : : : : : : : : : : : : : : : : : : : : : : : : : : 252 112 : : : : : : : : : : : : : : : : 266 1121 : : : : : : : : : : : : : : : : : : : : : : : : 266 1122 : : : : : : : : : : : : : : : : : : : : : : : : : : 271 1123 : : : : : : : : : : : : : : : : : : : : : : : : : 273 1124 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 276 12 Scheme 279 121 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 279 1211 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 279 1212 : : : : : : : : : : : : : : : : : : : : : : : : : : 281 122 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 282 1221 REP : : : : : : : : : : : : : : : : : 282 1222 : : : : : : : : : : : : : : : : : : : : 284 1223 : : : : : : : : : : : : : : : : : : : : : : : : : : 288 1224 ( 1) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 289 1225 ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : 290 1226 ( 2 ) : : : : : : : : : : : : : : : : : : : : : : : : 292 1227 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 294 1228 : : : : : : : : : : : : : : : : : : : : : : : : : 295 1229 : : : : : : : : : : 296 12210 ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : 299 12211 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 303 123 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 305 124 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 306 1241 : : : : : : : : : : : : : : : : 307 1242 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 308 A ASCII 313 B Scheme 315 C NGSCM 327 5
6 D Scheme 333 D1 Scheme : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 333 D2 FTP : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 335 336
Scheme W Clinger, J Rees ( ) \Revised 4 Report on the Algorithmic Language Scheme" ( R4RS) Scheme R4RS Scheme force delay R4RS Scheme (essential) R4RS ( ) } (scheme-proc arg) 4 (scheme-proc arg) p (scheme-proc arg) Scheme ( ) Typewrite Font Scheme Italic Typewrite Face Scheme ( )
1 (computer) ( ) ( ) ( (program) ) Scheme ( ) ( ) 1
2 1 q q ( ) q Hello World q q q q q q 11: 11 3 ( ) 1 ( ) 2 ( ) 3 ( ) 3 1 ( 11 ) 1 CPU Central Processing Unit I/O Input/Output
11 3 CRT X-Y 12: 1 (CPU) 2 (main memory) 3 (I/O device) 12 IC (Integrated Circuit ) LSI (Large Scale Integrated Circuit ) (memory cell) (bit) 0 1 ( ) 1
4 1 p p p p p p 2001 0000 1011 0011 1100 2002 1001 1100 1001 0000 2003 1110 0100 1100 1110 2004 0011 0110 0010 0001 p p p p p p 13: 16 32 1 (word) 1 0 1 5? 0 1 00000101 5 0 1 (binary number) ASCII A 65 65 01000001 0 1 0,1,2, 13 0 1
pp pp pp pp pp ppppp pppppppp pp 12 5 q q q q q q q p ppp p ppp ppp pp p p pp pp p pp p p p pp pp p pp p p pppp ppp ppp p p p ppp p ppppp ppp p p p p p pp pp p p p ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp p p p p p p p p p pp p p p p p p p p p p p p ppp q q q q q q q pppp pp p p p p p p ppppppppppppppp ppppppppppppppppppppppppppppppppppppppppp p p p p p p ppp q q q q q 1 q q q q q q N q q q q q q q p p p p ppppp pppp pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp p p p p pp ppppppppppppppppppppppppppppppppppp ppppppppppppppppppppppppppppppppppppppp ppppp pppppp ppppppp ppppppp pppppp 14: 12 13 ( ) ( ) (0 1 ) (native language) Scheme C Fortran ( ) ( ) ( 14 ) (register)
6 1 (program counter) ( ) 1 ( ) 2 3 ( 1 ) 4 100 101 2 102 MC6809 2 10001110 00000000 01100100 10100110 2 MC6809 8 65536 1 8
13 7 10000100 10101011 00000001 10100111 00000010 3 LDX #100 LDA,X ADDA 1,X STA 2,X 1 LDX #100 X 100 X 16 10001110, 00000000, 01100100 10001110 LDX # 00000000 01100100 100 3 2 LDA,X X A X 100 100 A 10100110 10000100 3 ADDA 1,X X 1 ( X 100 101 ) A A 10101011 00000001 X 2 ( X 100 102 ) A 10100111 00000010 13 ( ) (application program) 3
8 1 (system program) 131 (operating system)? 1 (multitasking) ( (multiprogramming)) 001 1
13 9 Unix 1960 AT&T (American Telephone & Telegram) MS-DOS MS-DOS Microsoft 1 132 0 1 ( 1 0 1!)
10 1 SUM: LDD #100 PSHS D LDD #0 PSHS D L: LDD 0,S ADDD 2,S STD 0,S LDD 2,S SUBD #1 STD 2,S BNE L LDD 0,S LEAS 4,S RTS 15: MC6809 (programming language) (high level language) Scheme 1 C, Lisp, Pascal, Fortran, Ada 1 100 15 MC6809 ( MC6809 ) 132(a), (b) Scheme, Pascal 15 ( ) ( )
13 11 (define (sum n) (if (= i 0) 0 (+ n (sum (- n 1))))) (sum 100) (a) Scheme PROGRAM Sum(input, output); VAR thesum, i : INTEGER; BEGIN thesum := 0; FOR i := 1 TO 100 DO thesum := thesum + i; WRITELN(thesum) END (b) Pascal (language processor) 4 NEC PC-9801 Apple Macintosh Macintosh Macintosh PC-9801 Macintosh PC-9801 4 ( CPU C )
12 1 5 (compiler) (interpreter) ( ) ( ) 133 (editor) (le) 5
13 13 (41 )
14 1 14 (waterfall model) 1 2
14 15 3 4 5 Alan W Biermann ( ), \,", 1993 M A Arbib, A J Kfoury, R N Moll (,, ), \," Information&Computing-1,, 1984 P AKidwell, P ECeruzzi ( ), \,", 1995
16 1 Bill Gates ( ), \,", 1995, \," 1,, 1988 Ullman ( ), \ ",, \," 6,, 1988 J L Peterson, A Silberschatz (, ), \,", 1987 G J Nutt, ( ), \ /,", 1992, \," 5,, 1989, \," 4,, 1994 N Wirth ( ), \,", 1986,, \The BUG,", 1995 F P Brooks Jr ( ), \,", 1977
2 Scheme Scheme NGSCM 1 Scheme Scheme Scheme Unix Unix 1 ( ) : MS-DOS : Unix 24 21 login: (cursor) 1 NGSCM Scheme NGSCM Appendix D 17
18 2 Scheme login: owl login: 1,2 ( ) pooh login: pooh RET RET login: pooh Password: 2 Last login: Thu Mar 16 20:32:25 from gull SunOS Release 412-JLE112 (GENERIC) #3: Fri Mar 5 15:34:42 JST 1993 % % (prompt) % > login: pooh Password: Login incorrect login: 2 Sun Unix SparcStation ELC SunOS 412 JLE 112
22 Scheme (NGSCM) 19 22 Scheme (NGSCM) Scheme NGSCM % ngscm RET 21 NGSCM Version 332 of 01/20/96 on owl (FreeBSD205-950622-SNAP) Copyright (C) 1992,1993,1994,1995,1996 Hirotsugu Kakugawa NGSCM is based on Ng editor by Shigeki Yoshida et al Type C-h for help (`C-' means use CTRL key) NGSCM comes with ABSOLUTELY NO WARRANTY You may give out copies of NGSCM; type C-h C-c to see the conditions Type C-h t for a tutorial on using NGSCM Type C-h T for a Japanese tutorial on using NGSCM Type C-j or C-c C-e to evaluate the expression before point Type C-g to abort evaluation SCM version 4e1, Copyright (C) 1990, 1991, 1992, 1993, 1994 Aubrey Jaffer SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)' This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 119 msec (0 in gc) 9993 cells work, 12800 bytes other > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 21: ngscm NGSCM ( ) NGSCM C-x C-c C-x C-c x c C- C-x C-c 1 C-x C-c ESC : 1,2 C-g C-x C-c
20 2 Scheme SCM version 4e1, Copyright (C) 1990, 1991, 1992, 1993, 1994 Aubrey Jaffer SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)' This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 105 msec (0 in gc) 9993 cells work, 12815 bytes other > [--]E_+--:--**-Mule: *scheme* 6:27pm 059 Mail (Inferior Scheme:run) Loading cmuschemedone 22: Mule Scheme 2 : Save file /home/pooh/honey-jar/lunchscm? (y or n) y 23 Scheme 231 Mule Mule % mule RET Mule ESC x run-scheme RET 22 (Mule Scheme SCM )
24 Scheme 21 Mule Scheme NGSCM RET Mule NGSCM C-x C-c Scheme emacs (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process" t) (setq scheme-program-name "scm") ( Scheme SCM "scm" ) 232 Scheme ( Scheme SCM ) % scm RET Scheme SCM, MIT Scheme, ELK, C-d C-d 24 Scheme Scheme 1 2 3 3 21 > > Scheme Scheme Scheme
22 2 Scheme 241 30+26 Scheme (+ 30 26) Scheme ( ) + ( ) 20 26 ( 20 26) (+ 30 26) DEL C-j ( j ) C-j (Scheme DEL BS ( C-j RET ) > (+ 30 26) C-j ;Evaluation took 0 msec (0 in gc) 0 cons work 56 (+ 30 26) ;Evaluation took 0 msec (0 in gc) 0 cons work ( ) 56 (= 30 + 26) > : > (+ 30 26) ;Evaluation took 0 msec (0 in gc) 0 cons work 56 > 4 5 > (* 4 5) C-j ;Evaluation took 0 msec (0 in gc) 0 cons work 20 >
25 23 > (+ 3 (* 2 4)) C-j ;Evaluation took 0 msec (0 in gc) 0 cons work 11 3+(2 4) (* 2 4) 8 3+8 11 Scheme 242 Scheme ( 7 ) (load) proc > (load "sumscm") C-j ;loading "sumscm" ;done loading "sumscm" ;Evaluation took 7 msec (0 in gc) 77 cells work, 87 bytes other #<unspecified> > "sumscm" 25 (logout) % logout RET login: : Scheme
24 2 Scheme Scheme 1 (+ 1 2 3) 2 (* 4 6) 3 (- 10 2) 4 (+ (* 2 3) 4) 5 (* (+ 1 2) (+ 3 4)) 6 (/ 100 (+ 1 1))
3 Scheme ( ) Scheme Scheme Scheme Scheme (NGSCM Mule ) 31 - - Scheme (Scheme ) > 2001 C-j ( j ) ( Scheme RET ) > 2001 C-j > 2001 ;Evaluation took 33 msec (0 in gc) 45 cons work 2001 > 2001 Scheme (Scheme ) 25
26 3 Scheme ( ) ;Evaluation took 33 msec (0 in gc) 45 cons work NGSCM ( Scheme ) : Scheme Scheme C-j 3+5 Scheme (+ 3 5) Scheme 3+5 (+ 3 5) ( ) + ( ) 3 5 + > (+ 3 5) 8 8 Scheme 1 2 3 (expression) 2001 ( ) (+ 3 5) 3 4+2 9 (* ) > (+ (* 3 4) (* 2 9)) 30 (+ (* 3 4) (* 2 9)) 3 4+2 9 (* 3 4) (* 2 9) 3 4 2 9 12 18 (+ 12 18) 30
32 27 > (+ (* (- 5 4) (- 3 1)) 10) 12 (+ (* (- 5 4) (- 3 1)) 10) = (+ (* 1 2) 10) = (+ 2 10) = 12 Scheme (Scheme (evaluation) ) ( ) 10 10 ( ) (a 0 a 1 a 2 a n ) a 0,,a n b 0,,b n b 1 ; :::; b n b 0 b 0 1 32 (variable) ( ) define } (define h i h i) h i h i 250000 income 1 a0 Scheme + +
28 3 Scheme ( ) > (define income 250000) #<unspecified> > income 250000 > (+ income 10000) 260000 #<unspecified> 2 define ( income) > (define expense (+ 10000 46000)) #<unspecified> > expense 56000 (define expense (+ 10000 46000)) expense (+ 10000 46000) expense expense 10000 (define 10000 56000) define 10000 56000 define Scheme (special form) ( ) set! } (set! h i h i) h i h i define set! tax 2 Scheme (define income 250000) define NGSCM #<unspecified> Scheme ( )
33 29 > tax Error: unbound variable: tax tax tax set! > (set! tax 15000) Error: unbound variable: tax define set! > (define tax 10000) #<unspecified> > tax 10000 > (set! tax 15000) #<unspecified> > tax 15000 : (define 'age 17) 'age (quote age) (define (quote age) 17) quote 'age quote (quote Scheme ) 33 Scheme (symbol)
30 3 Scheme ( ) > (define princess 'masako) #<unspecified> > princess masako (list) > (define friends '(yumiko mayuko hiroko noriko)) #<unspecified> > friends (yumiko mayuko hiroko noriko) 2 ' (quote) s 's (quote s) quote > (define masako 'owada) #<unspecified> > masako owada > (define princess masako) #<unspecified> > princess owada princess owada (define princess masako) masako owada princess ( masako princess masako ) friends? (yumiko mayuko hiroko noriko) yumiko mayuko hiroko noriko mayuko hiroko noriko yumiko : ', ( 103 )
34 31 princess friends (symbol) Scheme lambda FOOBAR ZAP!! number->string Okey? Mar21 acb3wdj $5 *the-state* this-identifyer-is-very-long-but-its-ok (+ - * / < = >!? : $ % ) ( 3 symbol? } (symbol? h i) h i #t #f #t yes #f no > (symbol? 'mayuko) #t > (symbol? 10) #f 34 (list) (yumiko mayuko hiroko noriko) ( ) : () (a) (NISHIDA HIKARU) (1 a 2 b) ((pi 31415) (e 271828)) (a (ba bb) (ca (cba cbb) cc) d) 3 -A
32 3 Scheme ( ) () (empty list) '() () '() 4 null? } (null? h i) h i #t #f > (null? '(yumiko mayuko)) #f > (null? '(yumiko)) #f > (null? '()) #t > (null? 'miho) #f 5 Scheme C Pascal Fortran 6 (pair) car cdr 7 car cdr 4 () (Scheme () Scheme ) 5 6 Scheme Pascal ( ) ( ) ( ) ( ) 7 1950 IBM IBM 7090 Lisp (Scheme ) IBM 7090 (address) (decrement) car Contents of Address part of Register cdr Contents of Decrement part of Register IBM 7090 car cdr
34 33 > (define idols '(hikaru miho hiroko noriko)) #<unspecified> > (car idols) hikaru > (cdr idols) (miho hiroko noriko)) car car cdr 2 3 > (car (cdr idols)) miho > (car (cdr (cdr idols))) hiroko > (car (cdr (cdr (cdr idols)))) noriko 3 4 car cdr car cdr (cadr S) (car (cdr S)) (cadar S) (car (cdr (car S))) car cdr 4 ( cadr, caddr, cadddr ) > (cadr idols) mami > (caddr idols) hiroko > (cadddr idols) noriko Scheme (pair) 31(a) 2 Scheme ( 31(c) 3 ) cons 8 cons 2 (cons a b) ( ) a ( ) b ( ) (cons 8 cons construct ( )
34 3 Scheme ( ) 2 3 (a) (b) (cons 2 3) 1 2 3 (c) (cons 1 (cons 2 3)) 31: a b) ( ) car cdr } (car h i) h i car } (cdr h i) h i cdr (a b) ( ) (cons 1 2) (1 2) ( 31(b) ) 2 ( ) (cons 1 (cons 2 3)) (1 (2 3)) (dotted notation) (a (b ())) (a b) (a1 (a2 (an ()) )) (a1 a2 an) (list notation) (cons 1 (cons 2 3))
34 35 () a b c 32: (a b c) > (cons 1 (cons 2 3)) (1 2 3) (1 (2 3)) (1 2 3) Scheme 9 (list) cdr cdr 32 cdr pair? list? } (pair? h i) h i #t #f } (list? h i) h i #t #f pair? ( car cdr ) list? cdr pair? list? > (pair? '(a b)) #t > (pair? '())! 9 (a1 (a2 (am (an ())) )) (a1 a2 am an)
36 3 Scheme ( ) #f > (pair? '(1 2)) #t > (list? '(a b c)) #t > (list? '()) #t > (list? '(1 2)) #f > (list? '(0 1 2)) #f list?, pair?, null? '() (pooh) (pooh piglet owl) (kanga roo) list? #t #t #t #f pair? #f #t #t #t null? #t #f #f #f 35 car, cdr, cons (1 2 3 4) (cons 1 (cons 2 (cons 3 (cons 4 '())))) '(1 2 3 4) a1, a2, a3, a4 : > '(a1 a2 a3 a4) (a1 a2 a3 a4) (cons a1 (cons a2 (cons a3 (cons a4 '())))) list } (list h 1 i h 2 i ) h 1 ih 2 i (h 1 i h 2 i )
35 37 > (define a 100) #<unspecified> > (define b 200) #<unspecified> > (list 1 2 3 4) (1 2 3 4) > (list a b) (100 200) > (list a '(a b) b) (100 (a b) 200) > (list a '(a b) 'b) (100 (a b) b) } (length h i) h i } (append h 1 i h 2 i ) h 1 i h 2 i } (reverse h i) h i } (list-ref h i i) h i i 4 (list-tail h i) h i > (length '(a b c d)) 4 > (length '(a b )) 2 > (length '()) 0 > (length '((a) (b c d))) 2 > (length '((a) (b c d) e))
38 3 Scheme ( ) 3 > (append (list 'a 'b) (list 'c 'd)) (a b c d) > (append (list 'a '(b c)) (list 'd 'e)) (a (b c) d e) > (reverse '(a b c d e)) (e d c b a) > (reverse '(a (b c) ((d)) e)) (e ((d)) (b c) a) > (reverse '()) () > (list-ref '(a b c d e) 0) a > (list-ref '(a b c d e) 1) b > (list-ref '(a b c d e) 4) e 36 ( 1) 2 Scheme ( ) 10 361 (boolean) #t #f if cond 11 (selfevaluating) > #t #t 10 11 Scheme #f
36 ( 1) 39 > #f #f > '#t #t boolean? } (boolean? h i) h i #t #f > (boolean? #t) #t > (boolean? #f) #t > (boolean? 10) #f > (boolean? '(1 2 3)) #f > (boolean? '()) #f not } (not h i) h i #f #t #f (h i ) > (not #t) #f > (not #f) #t > (not 10) #f > (not (cons 1 2)) #f > (not '()) #f
40 3 Scheme ( ) 362 Scheme (numbers) Scheme (integer) (rational) (real) (complex) 4 (Scheme ) 4 1:5 6:0 } (+ x 1 x 2 ) x 1 + x 2 + } (- x),x } (- x 1 x 2 ) x 1, x 2 4 (- x 1 x 2 x 3 ) x 1, x 2, x 3, ( ) } (* x 1 x 2 ) x 1 x 2 } (/ x) 1=x } (/ x 1 x 2 ) x 1 =x 2 4 (/ x 1 x 2 x 3 ) x 1 =(x 2 x 3 )( ) } (min x 1 x 2 ) x 1 ;x 2 ; } (max x 1 x 2 ) x 1 ;x 2
36 ( 1) 41 } (abs x) x } (floor x) x } (ceiling x) x } (truncate x) } (round x) > (+ 2 4) 6 6 > (+ 2 40) +60 60 > (- 2 3) -1 > (- 3) -3 > (* 30 45) +135 > (/ 10 5) 2 > (/ 10 50) +20 > (max 1 3 4 5 10 23) 23 > (min 4 2 8 10) 2 > (abs -8) 8 > (floor 103) 10 > (floor -103)
42 3 Scheme ( ) -11 > (ceiling 103) 11 > (ceiling -103) -10 > (round -103) -10 } (gcd n 1 n 2 ) } (lcm n 1 n 2 ) } (quotient n 1 n 2 ) } (remainder n 1 n 2 ) } (modulo n 1 n 2 ) gcd lcm quotient, remainder, modulo (quotient n 1 n 2 ) ) n 3 (remainder n 1 n 2 ) ) n 4 (modulo n 1 n 2 ) ) n 4 n 1 = n 2 n 3 + n 4 0 n 4 <n 2 (n 3 n 4 ) remainder modulo > (remainder 17 3) 2 > (modulo 17 3) 2 > (remainder -17 3) -2
36 ( 1) 43 > (modulo -17 3) 1 12 } (= x 1 x 2 ) x 1 = x 2 =? } (< x 1 x 2 ) x 1 <x 2 <? } (> x 1 x 2 ) x 1 >x 2 >? } (<= x 1 x 2 ) x 1 x 2? } (>= x 1 x 2 ) x 1 x 2? } (zero? x) x? } (positive? x) x? } (negative? x) x? } (odd? n) n? } (even? n) n? > (= 3 3 3) #t > (= 1 3 3) #f 12
44 3 Scheme ( ) > (< 3 4 5) #t > (<= 3 3 4 4 6) #t > (zero? 2) #f > (zero? 0) #t > (positive? 2) #t > (negative? -2) #t > (odd? 3) #t > (odd? 2) #f > (even? 2) #t } (number? x) x ( / / / ) #t #f } (integer? x) x #t #f x 0 #t } (real? x) x #t #f ( x #t ) > (number? 'foobar) #f > (number? 82) #t > (number? 2)
36 ( 1) 45 #t > (integer? 82) #f > (real? 82) #t > (integer? 2) #t > (integer? 20) #t > (real? 100) #t ( ) 10 3 3:3333 3 3:33333 real? 1 #t integer? 100 #t integer? real? Scheme (exactness) (exact number) (inexact number) } (exact? x) x #t #f } (inexact? x) x #t #f 4 (inexact->exact n) n
46 3 Scheme ( ) 4 (exact->inexact n) n > (exact? 1) #t > (integer? 10) #t > (exact? 10) #f > (real? 1) #t > (inexact? 1) #f > (inexact? 10) #t > (inexact->exact 44) 4 > (inexact->exact 45) 5 > (exact->inexact 4) 40 13 4 (exp x) e x (e ) 4 (log x) log e x 4 (sin x) sin x 4 (cos x) cos x 4 (tan x) tan x 13 Scheme
36 ( 1) 47 4 (asin x) sin,1 x 4 (acos x) cos,1 x 4 (atan x) tan,1 x 4 (atan y x) tan,1 y=x 4 (sqrt x) p x 4 (expt x y) x y 363 (string) " "honey" "Pooh and Piglet" "" "" (null string) > '"This is a string" "This is a string" > "This is a string" "This is a string" \ \" 14 14 \ =Y \ =Y
48 3 Scheme ( ) > "He said, \"Are you sure?\"" "He said, \"Are you sure?\"" > (display "He said \"Are you sure?\"") He said "Are you sure?"#<unspecified> display #<unspecified> #<unspecified> display ( ) string? } (string? h i) h i #t #f > (string? 'apple) #f > (string? "apple") #t > (string? 1924) #f } (string-length h i) h i ( ) } (substring h i x y) h i x y ( 0 ) y x y 0 (length h i) x y } (string-append h 1 i h 2 i h 1 i h 2 i > (string-length "Pooh and Piglet") 15 > (string-length "")
36 ( 1) 49 0 > (substring "Pooh, Owl, Piglet" 6 9) "Owl" > (substring "Pooh" 0 0) "" > (string-append "Winnie" "-" "the" "-" "Pooh") "Winnie-the-Pooh" } (string=? h 1 i h 2 i) h 1 i h 2 i? } (string-ci=? h 1 i h 2 i) h 1 i h 2 i? } (string<? h 1 i h 2 i) h 1 i h 2 i? } (string-ci<? h 1 i h 2 i) h 1 i h 2 i? } (string>? h 1 i h 2 i) h 1 i h 2 i? } (string-ci>? h 1 i h 2 i) h 1 i h 2 i? } (string<=? h 1 i h 2 i) h 1 i h 2 i? } (string-ci<=? h 1 i h 2 i) h 1 i h 2 i? } (string>=? h 1 i h 2 i) h 1 i h 2 i? } (string-ci>=? h 1 i h 2 i) h 1 i h 2 i? -ci a A "b" < "ba" < "baa" < "bb" < "c"
50 3 Scheme ( ) > (string=? "a b" "a b") #t > (string=? "a b" "a b c") #f > (string-ci=? "a b" "A B") #t > (string<? "aa" "ab") #t > (string<? "aa" "a") #f > (string>? "aba" "aaa") #t : "A"<"B"< ::: <"Z" : "a"<"b"< ::: <"z" : "0"<"1"< ::: <"9" : "A"<"a", "B"<"b", 15 16 37 2 2 = = 2 } (eqv? h 1 i h 2 i) } (eq? h 1 i h 2 i) } (equal? h 1 i h 2 i) 15;16 Scheme ( )
37 51 2 h 1 ih 2 i ( ) #t #f 2 #t 2 2 2 > (define qwe '(have fun)) #<unspecified> > (eqv? qwe qwe) #t > (eq? qwe qwe) #t > (equal? qwe qwe) #t #t 2 #f > (eqv? 'abc "2") #f > (eq? 'abc 314) #f > (equal? "314" 314) #f eqv? #t 2 #t #f 2 2 2 2 2 ( )
52 3 Scheme ( ) > (eqv? 'abc 'abc) #t > (eqv? 'foo 'bar) #f > (eqv? '() '()) #t > (eqv? 16 16) #t > (eqv? 16 (* 2 8)) #t > (eqv? 16 160) #f > (eqv? (list 'pooh 'piglet) (list 'pooh 'piglet)) #f > (define animal (list 'pooh 'piglet)) #<unspecified> > (eqv? animal animal) #t eqv? (eqv? "A" "A") 2 "A" eqv? 2 (eqv? '(1 2) '(1 2)) (eqv? '(b) (cdr '(a b))) eq? 2 ( ) #t eq? eqv? #t Scheme eq? =, eqv? equal? > (eq? 'a 'a) #t > (eq? 'a 'b) #f
38 53 > (eq? (list 'pooh 'piglet) (list 'pooh 'piglet)) #f > (define animal (list 'pooh 'piglet)) #<unspecified> > (eqv? animal animal) #t > (eq? '() '()) #t equal? ( 612 ) ( ) eqv? ( 2 equal? #t ) > (equal? '(a b) '(a b)) #t > (equal? (list 'a 'b) (list 'a 'b)) #t > (equal? '(a b (c d)) '(a b (c d))) #t > (equal? "my home" "my home") #t > (equal? 13 13) #t > (equal? 314 314) #t > (equal? 1 10) #f 38 (primitive procedure) (compound procedure) define 17 17 (compound procedure)
54 3 Scheme ( ) 1 add1 > (define (add1 n) (+ n 1)) #<unspecified> > (add1 1) 2 > (add1 99) 100 define (actual argument) (add1 1) 1 add1 n add1 add1 (+ n 1) n add1 (formal argument) n add1 add1 n add1 n n add1 add1 > (define n 10) #<unspecified> > n 10 > (add1 1) 2 > n 10 n 10 add1 n 10 add1 n add1 1 10 2 > (define (distance x y) (sqrt (+ (* x x) (* y y)))) #<unspecified> > (distance 1 1) +1414213562373095 > (distance 2 4) +447213595499958
38 55 (define (h i h i) h 1 i h 2 i h n i ) h i h i (h i h i) (define count 0) define add1 (define add1 (lambda (n) (+ n 1))) (lambda ) ( expression) (procedure) } (lambda h i h i) h i h i } (procedure? h i) h i #t #f 1 (lambda (n) (+ n 1)) 1 define > ((lambda (n) (+ n 1)) 10) 11
56 3 Scheme ( ) (lambda (n) (+ n 1)) 1 10 10 > (add1 10) 11 add1 1 10 10 > (define (calc x op y) (op x y)) #<unspecified> > (calc 3 + 4) 7 > (calc 2-8) -6 > (calc 3 * 6) 18 +, -, * calc op (op x y) op x y calc (x op y) (calc 2) : > (calc 2) Error: Wrong number of args to in excpression: ( calc 2) in top level environment ; Evaluation took 50msec + 2 4
39 57 (foo (list a b c d e)) 1 foo 1 (define h i (lambda h i h i )) h i (define foo (lambda s (if (null? s) '() (list-ref s (- (length s) 1))))) foo (foo 1 2 3 4) s (1 2 3 4) > (foo 1 2) 2 > (foo 1 2 3 4 5) 5 > (foo) () 39 f(x) =x 4 + g(x)x 2 f1 (g(x) g ) (define (f1 x) (+ (* x x x x) (* (g x) x x))) x x x x + g(x) x x f y = x 2 y y + y f1 f2 :
58 3 Scheme ( ) (define y 0) (define (f2 x) (set! y (* x x)) (+ (* y y) (* (g x) y))) ( (define y 0) y y 0 ) f1 g y g y f2 (local variable) Scheme let, let*, letrec let let* letrec 64 391 let f f (define (f x) (let ((y (* x x))) (+ (* y y) (* (g x) y)))) let } (let ((h 1 i h 1 i) (h 2 i h 2 i) (h n i h n i)) h i) h i let h 1 i, h 2 i,, h n i h 1 i, h 2 i,, h n i h 1 i, h 2 i,,h n i h i h 1 i,h 2 i,,h n i h i h i let let let
39 59 > (define x 10) #<unspecified> > x 10 > (let ((x 7)) (set! x (* x x)) x) 49 > x 10 let x set! 49 x > (define x 1) #<unspecified> > (define y 3) #<unspecified> > (let ((a (+ y 1)) (b (* x 2))) (+ a b)) 6 > (let ((x (+ y 1)) (y (* x 2))) (+ x y)) 6 (+ y 1) (* x 2) x y let ( 4 2 ) let let 392 let* let* 4 (let* ((h 1 i h 1 i) 18 (h 2 i h 2 i) (h n i h n i)) h i) 18 Scheme
60 3 Scheme ( ) let* let let > (define x 1) #<unspecified> > (define y 3) #<unspecified> > (let* ((x (+ y 1)) (y (* x 2))) (+ x y)) 12 (+ y 1) 4 x (* x 2) y x y 4 let let*? (let ((x 0)) (let ((x 1)) x)) 1 (let ((x 1) 1 310 ( 1) 3101 if if 2 foo n 0 zero non-zero (define (foo n) (if (zero? n) 'zero 'non-zero))
310 ( 1) 61 > (foo -1) non-zero > (foo 0) zero > (foo 68000) non-zero if } (if h i h 1 i h 2 i) h i ( #f ) h 1 i if h 2 i if h 2 i 4 (if h i h i) 19 h i ( #f ) h i if if 20 3102 cond cond (define (score n) (cond ((<= n 50) 'fail) ((< n 70) 'poor) ((< n 80) 'fair) (else 'excellent))) 19 Scheme 20
62 3 Scheme ( ) score n 50 fail 51 70 poor 70 80 fair 80 excellent : > (score 30) fail > (score 67) poor > (score 79) fair > (score 96) excellent cond } (cond h 1 i h 2 i h n i) cond cond- (cond-clause) h i h i (h 1 i h 1 i ) h i ( #f ) h i cond #f h n i else h n i cond cond score2 (define (score2 n) (cond ((< n 80) 'fair)
310 ( 1) 63 ((< n 70) 'poor) ((<= n 50) 'fail) (else 'excellent))) > (score2 30) fair 30 fair 3103 begin begin begin > (define x 10) #<unspecified> > (define y 3) #<unspecified> > (begin (display "10 * 3 = ") (display (* 10 3)) (newline)) 10 * 3 = 30 #<unspecified> display newline ( ) begin } (begin h 1 i h 2 i h n i) h 1 i,h 2 i h n i h n i begin begin
64 3 Scheme ( ) (side eect) set! display 3104 and or and or and } (and h 1 i h 2 i h n i) h 1 i ( #f ) h 2 i h n i and and #f and > (define x 10) #<unspecified> > (and (number? x) (> x 0) (+ x 1)) 11 (number? x) (> x 0) (+ x 1) 11 and > (and (number? x) (> x 100) (+ x 1)) #f (> x 100) and #f and and ( )
311 65 x (+ x 1) 1 or } (or h 1 i h 2 i h n i) or h 1 i #f h 2 i #f or or or or > (define x -20) #<unspecified> > (if (or (< x 0) (> x 100)) "x < 0 or 100 < x" "else") "x < 0 or 100 < x" x -20 (< x 0) or > (if (or (= x 0) (> x 0)) "x >= 0" "x < 0") "x < 0" or or #f if "x < 0" 311 Scheme (recursion) : Pascal, C, Fortran Pascal FOR Fortran
66 3 Scheme ( ) DO Scheme 1011 (recursion) Scheme fact (define (fact n) (if (= n 0) 1 (* n (fact (- n 1))))) 1 n n! = 1 2 (n, 1) n (fact 4) (fact 4) ) (* 4 (fact 3)) ) (* 4 (* 3 (fact 2))) ) (* 4 (* 3 (* 2 (fact 1)))) ) (* 4 (* 3 (* 2 (* 1 (fact 0))))) ) (* 4 (* 3 (* 2 (* 1 1)))) ) (* 4 (* 3 (* 2 1))) ) (* 4 (* 3 2)) ) (* 4 6) ) 24 (fact 4) 4 (fact 3) (fact 3) 3 (fact 2) (fact 2) 2 (fact 1) (fact 1) 1 (fact 0) (fact 0) 1 (fact 1) 1 1=1 (fact 2) 2 1=2 (fact 3) 3 2=6
311 67 (fact 4) 4 6=24 (recursion) 21 l l l 0 (cdr l) 1 l (define (len l) (if (null? l) 0 (+ (len (cdr l)) 1))) l (cdr l) l (null? l) fact (fact n) (fact n, 1) n (fact n, 1) n (fact 5) 1 n n fact2 (define (fact2 n) (define (fact-sub n f) (if (= n 0) f (fact-sub (- n 1) (* f n)))) (fact-sub n 1)) 21 f g g f (mutual recursion)
68 3 Scheme ( ) (fact2 4) (anonther-fact 4) ) (fact-sub 4 1) ) (fact-sub 3 4) ) (fact-sub 2 12) ) (fact-sub 1 24) ) (fact-sub 0 24) ) 24 fact2 fact-sub 1 n 0 fact-sub Scheme fact2 n (stack) f g g f g g g f g f f ( ) fact n ( ) fact2 (tail recursive) A B B B A B B A
312 69 312 Scheme Scheme ( (load) ) } (load h i) h i Scheme h i 4 (transcript-on h i) h i h i 4 (transcript-off) transcript-on Scheme transcript-on transcript-off load h i Scheme sin-tablescm ;; sqrt-tablescm ;; --- prints values of square root of 110 (define (print-sqrt-table from to) (print-sqrt-table2 from to)) (define (print-sqrt-table2 i to) (if (> i to) 'done (begin (display i) (display " ") (display (sqrt i)) (newline) (print-sqrt-table2 (+ i 1) to)))) (print-sqrt-table 1 10)
70 3 Scheme ( ) (print-sqrt-table 1 10) > (load "sqrt-tablescm") ;loading "prog/sqrt-tablescm" 1 10 2 14142135623731 3 173205080756888 4 20 5 223606797749979 6 244948974278318 7 264575131106459 8 282842712474619 9 30 10 316227766016838 ;done loading "sqrt-tablescm" ;Evaluation took 14 msec (0 in gc) 216 cells work, 212 bytes other #<unspecified> > transcript-on transcript-off > (transcript-on "LOG-FILE") ;Evaluation took 0 msec (0 in gc) 6 cells work, 37 bytes other #<unspecified> > (+ 1 2 3) ;Evaluation took 0 msec (0 in gc) 11 cells work, 37 bytes other 6 > (* 1 2 3 4 5 6 7 8 9 010) ;Evaluation took 0 msec (0 in gc) 32 cells work, 51 bytes other 3628800 > (transcript-off) #<unspecified> LOG-FILE transcript-on transcript-off : ;Evaluation took 0 msec (0 in gc) 6 cells work, 37 bytes other #<unspecified> > (+ 1 2 3) ;Evaluation took 0 msec (0 in gc) 11 cells work, 37 bytes other 6 > (* 1 2 3 4 5 6 7 8 9 010) ;Evaluation took 0 msec (0 in gc) 32 cells work, 51 bytes other 3628800 > (transcript-off) transcript-on transcript-off Scheme ( )
312 71 Scheme Scheme ( ) 6 Scheme Appendix B Scheme
72 3 Scheme ( )
4 NGSCM Mule Appendix NGSCM 7 8 41, (editor) 1 41 (editing buer) ( (buer) ) (text) (save) 73
74 4 NGSCM q (define (qweqwe n) (if (= n 1) 1 (* n (qweqwe (- n 1))))) q p A quick brown fox jumps over a lazy dog She sells sea shells in the sea shore p p p 41: (window) ( ) (cursor) 42 NGSCM NGSCM 421 1 NGSCM 42
42 NGSCM 75 --**-NGSCM: *scheme* Find file: (-EE:fundamental-Scheme Interaction)-- 42: ( ) 422 ;; ;; fact - compute factorial ;; (define (fact n) (define (fact2 n f) (if (= n 1) f (fact2 (- n 1) (* n f)))) (fact2 n 1)) --**-NGSCM: qwescm (-EE:fundamental-Scheme)-------------- under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 316 msec (0 in gc) 8829 cons work ;Evaluation took 0 msec (0 in gc) 9 cons work #<unspecified> > (fact 10) ;Evaluation took 16 msec (0 in gc) 56 cons work 3628800 > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 43: NGSCM NGSCM 43 2 --**-NGSCM: qwescm (-EE:fundamental-Scheme)-------------- 44:
76 4 NGSCM qwescm *scheme* (mode line) --**-NGSCM: -----NGSCM: NGSCM: 43 qwescm ( ) *scheme* ( ) 2 (-EE: NGSCM Mule fundamental-scheme fundermental ( ) Scheme Scheme 43 NGSCM NGSCM 431 NGSCM % ngscm RET % Unix % ngscm sumscm RET
44 77 sumscm NGSCM 432 NGSCM % ngscm RET NGSCM C-x C-f 715 433 NGSCM C-x C-c (C-x C-c CTL x CTL c ) NGSCM Save file /home/pooh/sumscm? (y or n) y n NGSCM ( /home/pooh/sumscm ) ( NGSCM ) 44 NGSCM ( : 8 Scheme ) n 1 n Scheme 1 n n =1 1
78 4 NGSCM n, 1 n ( 1 n =1 sum(n) = sum(n, 1) + n Scheme (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) sumscm scm Scheme scm Scheme scm -----NGSCM: sumscm (New file) (-EE:fundamental-Scheme)-------------- 45: ngscm sumscm NGSCM % ngscm sumscm RET
44 79 C-p q C-b q q q C-f C-n 46: 45 sumscm sumscm (New file) sumscm NGSCM ( ) (control key) C-b 1 (b backward character b) C-f 1 (f forward character f) C-p (p previous line p) C-n (n next line n) C-d 1 (d delete character d) DEL 1 RET
80 4 NGSCM 46 ( 47 ) (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) --**-NGSCM: sumscm (-EE:fundamental-Scheme)-------------- 47: sum ) ( Scheme C-x 2 48 2 48 (define ) C-c C-e C-c C-e ( (define (sum n)) ) Scheme ( ) Scheme sum C-c C-e 49 ( ) Scheme sum C-x o Scheme ( 410) C-j (sum 10) (sum 10) C-j 411
44 81 (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) --**-NGSCM: sumscm (-EE:fundamental-Scheme)-------------- This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 119 msec (0 in gc) 9993 cells work, 12800 bytes other ;Evaluation took 0 msec (0 in gc) 36 cells work, 41 bytes other #<unspecified> > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 48: C-x 2 2 (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) --**-NGSCM: sumscm (-EE:fundamental-Scheme)-------------- This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 119 msec (0 in gc) 9993 cells work, 12800 bytes other ;Evaluation took 0 msec (0 in gc) 36 cells work, 41 bytes other #<unspecified> > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 49: C-c C-e
82 4 NGSCM (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) --**-NGSCM: sumscm (-EE:fundamental-Scheme)-------------- This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 119 msec (0 in gc) 9993 cells work, 12800 bytes other ;Evaluation took 0 msec (0 in gc) 36 cells work, 41 bytes other #<unspecified> > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 410: C-x o Scheme (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) --**-NGSCM: sumscm (-EE:fundamental-Scheme)-------------- This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 119 msec (0 in gc) 9993 cells work, 12800 bytes other ;Evaluation took 0 msec (0 in gc) 36 cells work, 41 bytes other #<unspecified> > (sum 10) ;Evaluation took 7 msec (0 in gc) 34 cells work, 33 bytes other 55 > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 411: (sum 10)
44 83 : 1 C-x o 2 3 C-c C-e ( ) Scheme 4 C-x o Scheme (sum 10) C-j 10 NGSCM C-x C-c : Save file /home/pooh/sumscm? (y or n) ( /home/pooh/sumscm ) y n NGSCM : 1 RET (* (+ 1 2) (* (+ 3 4) (+ 5 6)) (+ 7 (* 8 2))) 1 (* (+ 1 2) (* (+ 3 4) (+ 5 6)) (+ 7 (* 8 2))) (+ 1 2) (* (+ 3 4) (+ 5 6)) (+ 7 (* 8 2))
84 4 NGSCM : (innite loop) ( Garbage collecting Garbage collectingdone ) C-g Scheme 1 1 NGSCM 2 3 Ctlx2 2 4 C-c C-e Scheme 5 C-x o Scheme ( C-g ) 6 4 7 C-x C-c NGSCM 441 Mule Unix Mule Scheme 1 Mule % mule sumscm RET 2 3 C-x 2 2 1 Scheme C-c
44 85 SCM version 4e1, Copyright (C) 1990, 1991, 1992, 1993, 1994 Aubrey Jaffer SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)' This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 91 msec (0 in gc) 9993 cells work, 12815 bytes other > [--]E_+--:--**-Mule: *scheme* 4:53pm 031 Mail (Inferior Scheme:run) (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) [--]E:-----Mule: sumscm 4:53pm 031 Mail (Scheme)--All------------ 412: Mule Scheme 4 Scheme M-x run-scheme RET Scheme M-x run-scheme ESC x run-scheme RET ( 412 ) 5 RET 6 C-x o Scheme C-c C-e 442 Scheme NGSCM Scheme vi Scheme SCM 1 vi (vi NGSCM vi ) % vi sumscm RET 2
86 4 NGSCM 3 Scheme % scm SCM version 4e1, Copyright (C) 1990, 1991, 1992, 1993, 1994 Aubrey Jaffer SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)' This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 333 msec (0 in gc) 8829 cons work > 4 load > (load "sumscm") RET 5 C-c ( C-c C-g ) 6
5 Scheme 1 2 3 1: ( addressscm ) 77 44 2 87
88 5 * (* ) ( )
51 89 51 (rational) a=b 3=10;,1=3; 101=9 Scheme ( ) 1 make-rat is-rat? rat-num rat-den rat:+ 511 (make-rat a b) a b 2 (is-rat? r) r #t #f 1 14 2 rat rational
90 5 3 ( rat) make-rat (define (make-rat a b) (list 'rat a b)) rat ' (quote) rat rat rat Scheme car is-rat? (define (is-rat? r) (eq? (car r) 'rat)) eq? 2 rat Scheme 2 > (define r1 (make-rat 1 3)) 1/3 #<unspecified> > (is-rat? r1) r1? #t is-rat? 3 > (is-rat? 10) ERROR: car: Wrong type in arg1 10! car is-rat? r car 3 10 = 10=1 10 10
51 91 car list? is-rat? (define (is-rat? r) (and (list? r) (eq? (car r) 'rat))) and #f #f #f and 4 r 1 r 2 [ ] [ ] [ ] [ ] r 1 + r 2 = r 1 r 2 + r 1 r 2 r 1 r 2 r 1, r 2 = r 1 r 2, r 1 r 2 r 1 r 2 r 1 r 2 = r 1 r 2 r 1 r 2 r 1 =r 2 = r 1 r 2 r 1 r 2 rat-num rat-den 5 s i (list-ref s i) ( 0 ) error error ( error Scheme ) rat-num, rat-den 4 and 10 5 numerator, denominator
92 5 (define (rat-num r) (if (is-rat? r) (list-ref r 1) (error "rat-num - not rational number"))) (define (rat-den r) (if (is-rat? r) (list-ref r 2) (error "rat-den - not rational number"))) error rat-num - not rational number > (define r (make-rat 1 3)) #<unspecified> > (rat-num r) 1 > (rat-den r) 3 > (rat-den 10) Error: rat-num - not rational number > rat:+ (define (rat:+ r1 r2) (if (and (is-rat? r1) (is-rat? r2)) (make-rat (+ (* (rat-num r1) (rat-den r2)) (* (rat-den r1) (rat-num r2))) (* (rat-den r1) (rat-den r2))) (error "rat:+ - not rational number"))) : (define (rat:+ r1 r2) (if h r1 r2?i (make-rat
51 93 h i h i ) h i )) 2 r1 r2 make-rat 2 error > (define r (make-rat 1 3)) 1/3 #<unspecified> > (define s (make-rat 2 5)) 2/5 #<unspecified> > (define t (rat:+ r s)) t = 1/3 + 2/5 #<unspecified> > (rat-num t) 11 11 > (rat-den t) 15 15 1=3+2=5 =11=15 : (define (rat:- r1 r2) (if (and (is-rat? r1) (is-rat? r2)) (make-rat (- (* (rat-num r1) (rat-den r2)) (* (rat-den r1) (rat-num r2))) (* (rat-den r1) (rat-den r2))) (error "rat:- - not rational number"))) 512
94 5 a b make-rat a=b rat-num a a=b rat-den b 51: make-rat, rat-num, rat-den, is-rat? make-rat, rat-den, rat:+ (data abstraction) (abstract data type) (information hiding)
51 95 (message passing) 1 rat:* 2 f f(r) =r + r 2 + r 3 ( r ) f rat:+ rat:* 3 rat:/ 4 rat:inv 5 display write (rational-number 11 15) 11/15 rat:print ( : display write ) 6 reducible? #t #f ( : a b (gcd a b) ) 7 rat:reduce 8 rat:reduce 9 10 2 2 r 1 r 2 (1) 2 (2) (3) r 1 + r 2 (4)
96 5 rat:show+ 2 + 1 1 + 3 3 4 8 8 > (rat:show+ (make-rat 2 3) (make-rat 1 4)) (2/3) + (1/4) Tsuubun Shimasu = (4/4)*(2/3) + (3/3)*(1/4) = (8/12) + (3/12) Tashi Masu = ((8+3)/12) Kotae Desu = (11/12) > (rat:show+ (make-rat 1 8) (make-rat 3 8)) (1/8) + (3/8) Bunbo ga Onaji Tashi Shimasu = ((1+3)/8) Kotae Desu = (4/8) Yakubun Shimasu = ((4*1)/(4*2)) Yakubun Shita Kotae Desu = (1/2) 11 (rat:+ (make-rat 1 2) 2) 5=2 (rat:+ 1 2) 3=1 exact? (exact? 613 ) 12 rat:+ (rat:+ (make-rat 1 2) 12) 1:7 inexact? (inexact? 613 ) 13 make-rat
51 97 14 * 1=1 1
98 5 52 (recursion) ( 1) (3 6 pooh piglet 9) 3 (pooh) 0 ( (1 (2 3) 4 ) s 1: s s 0 2: s : 1 2-1: s car : (cdr s) 1 s 2 2-2: s car : (cdr s) s
52 99 count-numbers-1a (define (count-numbers-1a s) (if (null? s) 0 1 (if (number? (car s)) (+ (count-numbers-1a (cdr s)) 1) 2-1 (count-numbers-1a (cdr s))))) 2-2 if cond (define (count-numbers-1b s) (cond ((null? s) 0) 1 ((number? (car s)) (+ (count-numbers-1b (cdr s)) 1)) 2-1 (else (count-numbers-1b (cdr s))))) 2-2 > (count-numbers-1a '(3 6 pooh piglet 9)) 3 > (count-numbers-1a '(pooh piglet)) 0 > (count-numbers-1a '()) 0 > (count-numbers-1a '(3 6 9)) 3 ' (quote) ( ) (count-numbers1a '(3 6 pooh piglet 9)) (count-numbers1a (3 6 pooh piglet 9)) Scheme (3 6 pooh piglet 9) > (count-numbers1a (3 6 pooh piglet 9))
100 5 ERROR: Wrong type to apply: (see errobj) ; in expression: ( 3 6 pooh piglet 9) ; in top level environment > ' ( 2) ((3 alice 6) hatter (9 2)) 4 ((3 alice 6) hatter ((1 2) (3 4))) 6 ((3 alice 6) ((1 (2)))) 4 s count-numbers-1a car 1: s s 0 2: s : 1 2-1: (car s) : (car s) (cdr s) s 2 2-2: (car s) : (cdr s) 1 s 3 2-3: : (cdr s) s count-number-2a (define (count-numbers-2a s) (if (null? s) 0 1
52 101 (cond ((list? (car s)) (+ (count-numbers-2a (car s)) (count-numbers-2a (cdr s)))) 2-1 ((number? (car s)) (+ (count-numbers-2a (cdr s)) 1)) 2-2 (else (count-numbers-2a (cdr s)))))) 2-3 (1 2 rabbit owl) (1 2) (pooh honey) () (4 5 6) (4 5 6) s 1: s 2: s 1 2-1: (car s) (car s) (cdr s) cons 2 2-2: (car s) (cdr s) (define (collect-numbers s) (if (null? s) '() 1 (if (number? (car s)) (cons (car s) (collect-numbers (cdr s))) 2-1 (collect-numbers (cdr s))))) 2-2
102 5 (0 1 2 3) (0 1 4 9) () () s 1: s 2: s (car s) (cdr s) cons (define (squared-numbers s) (if (null? s) '() 1 (cons (* (car s) (car s)) 2 (squeared-numbers (cdr s))))) 1 (0-1 2-3) 0 (pooh piglet 2001) 2 (1192 538 (owl rabbit)) 0 2 ( ) (0-1 2-3) 0 (pooh piglet 2001) 2 (1192 538 (owl rabbit)) 2
52 103 3 0 (0-1 2-3) 2 (pooh piglet 2001) 1 (1192 538 (owl rabbit)) 2 4 5 6 num sym ( ) (1 pooh honey 2) (num sym sym num) (owl rabbit) (sym sym) () () 7 ( : string-append) ("Winnie" "-the-" "Pooh") "Winnie-the-Pooh" ("Pooh") "Pooh"
104 5 53 1: 2 94 ( 2: ) ( ) A 1 2 A 3 A 4 5 ( ) (!) ( )
53 1: 105 531 *ADDRESS-BOOK* *ADDRESS-BOOK-OPENED* (open) (close) 6 *ADDRESS-BOOK-STATE* ;;; (define *ADDRESS-BOOK* '()) ;;; (define *ADDRESS-BOOK-STATE* #f) ; (define *ADDRESS-BOOK-OPENED* #f) ; ; ; 7 (yumiko 01-23-4567) ((mayuko 01-23-4567) (misako 09876-7-654) (hikaru 56-7890) ) 6 7 ;
106 5 car ( ) make-address-item 8 ; (define (make-address-item name phone) (list name phone)) ; (define (get-name item) (car item)) ; (define (get-phone item) (cadr item)) ; (define (make-new-address-book) (set! *ADDRESS-BOOK* '())) cons add-to-address-book 8 Scheme
53 1: 107 *ADDRESS-BOOK* *ADDRESS-BOOK-STATE* () Misako 999-9999 Mayuko 12-3456 Narimi 98-7654 Chisato 012-345-6789 52: ; (define (add-to-address-book name phone) (set! *ADDRESS-BOOK* (cons (make-address-item name phone) *ADDRESS-BOOK*))) make-address-item 2 (address-book) Chisato, Mayuko, Narimi, Misako 4 ; (define (address-book) (make-new-address-book) (add-initial-address)) ;;; (define (add-initial-address) (add-to-address-book 'Chisato '012-345-6789) (add-to-address-book 'Narimi '98-7654) (add-to-address-book 'Mayuko '12-3456) (add-to-address-book 'Misako '999-9999)) *ADDRESS-BOOK-OPENED*
108 5 *ADDRESS-BOOK-OPENED* ; (define (open-address-book) (set! *ADDRESS-BOOK-STATE* *ADDRESS-BOOK*) (set! *ADDRESS-BOOK-OPENED* #t)) ; (define (close-address-book) (set! *ADDRESS-BOOK-OPENED* #f)) 52 *ADDRESS-BOOK* *ADDRESS-BOOK-STATE* cdr read-address 2 lookup-address next-address lookup-address *ADDRESS-BOOK-STATE* lookup-address ; ( ) (define (lookup-address) (if *ADDRESS-BOOK-OPENED* (car *ADDRESS-BOOK-STATE*) (error:not-opened))) *ADDRESS-BOOK-OPENED* *ADDRESS-BOOK-STATE* ( ) next-address *ADDRESS-BOOK-STATE*
53 1: 109 ; (define (next-address) (if *ADDRESS-BOOK-OPENED* (set! *ADDRESS-BOOK-STATE* (cdr *ADDRESS-BOOK-STATE*)) (error:not-opened))) 2 read-address ; ( ) (define (read-address) (if *ADDRESS-BOOK-OPENED* (let ((value (lookup-address))) (next-address) value) (error:not-opened))) *ADDRESS-BOOK-STATE* (car *ADDRESS-BOOK-STATE*) car end-of-address-book? ; (define (end-of-address-book?) (if *ADDRESS-BOOK-OPENED* (null? *ADDRESS-BOOK-STATE*) (error:not-opened))) (define (error:opened) (error "Already opened")) (define (error:not-opened) (error "Not opened")) error ( )
110 5 ;;; addressscm ( ) ;;; (define *ADDRESS-BOOK* '()) ;;; (define *ADDRESS-BOOK-STATE* #f) ; (define *ADDRESS-BOOK-OPENED* #f) ; ;;; ; (define (make-address-item name phone) (list name phone)) ; (define (get-name item) (car item)) ; (define (get-phone item) (cadr item)) ;;; ; (define (make-new-address-book) (set! *ADDRESS-BOOK* '())) ; (define (add-to-address-book name phone) (set! *ADDRESS-BOOK* (cons (make-address-item name phone) *ADDRESS-BOOK*))) ; (define (address-book) (make-new-address-book) (add-initial-address)) ;;; (define (add-initial-address) (add-to-address-book 'Chisato '012-345-6789) (add-to-address-book 'Narimi '98-7654) (add-to-address-book 'Mayuko '12-3456) (add-to-address-book 'Misako '999-9999)) ;;; ; (define (open-address-book) (set! *ADDRESS-BOOK-STATE* *ADDRESS-BOOK*) (set! *ADDRESS-BOOK-OPENED* #t)) ; (define (close-address-book) (set! *ADDRESS-BOOK-OPENED* #f))
53 1: 111 ; ( ) (define (read-address) (if *ADDRESS-BOOK-OPENED* (let ((value (lookup-address))) (next-address) value) (error:not-opened))) ; ( ) (define (lookup-address) (if *ADDRESS-BOOK-OPENED* (car *ADDRESS-BOOK-STATE*) (error:not-opened))) ; (define (next-address) (if *ADDRESS-BOOK-OPENED* (set! *ADDRESS-BOOK-STATE* (cdr *ADDRESS-BOOK-STATE*)) (error:not-opened))) ; (define (end-of-address-book?) (if *ADDRESS-BOOK-OPENED* (null? *ADDRESS-BOOK-STATE*) (error:not-opened))) ;;; (define (error:opened) (error "Already opened")) (define (error:not-opened) (error "Not opened")) 532 (address-book) (add-to-address-book h i h i) (open-address-book) (close-address-book)
112 5 (lookup-address) (next-address) (read-address) (end-of-address-book?) (application program) ( ) ( ) (application interface) API 533 phone (define (phone name) (let ((phone-number #f)) (open-address-book) (set! phone-number (search-phone name)) (close-address-book) phone-number)) serach-phone 1 1 search-phone
ppppppppp ppppppppppppppppppp ppp 53 1: 113 pppp ppppppppp pp ppp p p p p p phone open-address-book close-address-book lookup-address read-address car cdr cons null? Scheme 53: 3 search-phone (define (search-phone name) (if (end-of-address-book?)? "Not found" "Not Found" (let ((item (read-address))) (if (equal? name (get-name item)) (get-phone item) (search-phone name))))) > (address-book) #<unspecified> > (phone 'Mayuko)? 12-3456 > (phone 'Hiroko)? "Not found"
114 5 534 ( ) ( read-addres) (94 ( 2: ) ) 53 Scheme cons, car, null? Scheme read-address, lookup-address Scheme 1 show-all 2 phone-to-name
53 1: 115 3 4 name-to-address 5 age-from-to (age-from-to f t) f t 6 birthday-people ( ) 7 ( ) 8 ** ( ) (1)? (2)? 1 53
116 5
6 Scheme ( ) 3 Scheme ( ) Scheme Scheme (1) ( ) (2) (3) (4) 61 ( 2) 611 (character) A 6 Scheme #\A ( A) #\b ( b) #\h i #\h i #\h i > #\A #\A#<unspecified> > #\b #\b#<unspecified> > (display #\A) A#<unspecified> > (display #\b) b#<unspecified> 117
118 6 Scheme ( ) #\h i h i (control character) 1 #\space > (display #\space) #<unspecified> > (display #\tab) #<unspecified> > (display #\del) ^?#<unspecified> > (display #\bel) ^G#<unspecified> ASCII Appendix A #\h i #\h i / > (equal? #\A #\A) #t > (equal? #\A #\a) #f > (equal? #\tab #\tab) #t > (equal? #\tab #\TAB) #t > (equal? #\tab #\TaB) #t ASCII A (10 ) 65 2 (character code) } (char->integer h i) h i 1 A z (Appendix A ) 2 (character set) ASCII EBCDIC
61 ( 2) 119 } (integer->char h i) h i A B -ci 3 } (char=? h 1 i h 2 i) h 1 i = h 2 i? } (char<? h 1 i h 2 i) h 1 i < h 2 i? } (char>? h 1 i h 2 i) h 1 i > h 2 i? } (char<=? h 1 i h 2 i) h 1 ih 2 i? } (char>=? h 1 i h 2 i) h 1 ih 2 i? } (char-ci=? h 1 i h 2 i) h 1 i = h 2 i? } (char-ci<? h 1 i h 2 i) h 1 i < h 2 i? } (char-ci>? h 1 i h 2 i) h 1 i > h 2 i? } (char-ci<=? h 1 i h 2 i) h 1 ih 2 i? } (char-ci>=? h 1 i h 2 i) h 1 ih 2 i? 3 -ci case insensitive /
120 6 Scheme ( ) > (char=? #\A #\A) #t > (char=? #\A #\a) #f > (char-ci=? #\A #\a) #t > (char<? #\G #\H) #t > (char<? #\G #\G) #f > (char>? #\5 #\8) #t char? } (char? h i h i #t #f > (char? #\A) #t > (char? "A") #f } (char-alphabetic? h i) h i? } (char-numeric? h i) h i? 0,1,,9 } (char-whitespace? h i) h i? (ASCII ) (space) (tab) (line feed) (form feed) (carriage return) } (char-upper-case? h i) h i? } (char-lower-case? h i) h i?
61 ( 2) 121 > (char-alphabetic? #\b) #t > (char-alphabetic? #\4) #f > (char-number? #\z) #f > (char-number? #\0) #t > (char-whitespace? #\space) #t > (char-whitespace? #\tab) #t > (char-upper-case? #\A) #t > (char-upper-case? #\b) #f > (char-lower-case? #\A) #f > (char-lower-case? #\z) #t } (char-upcase h i) h i 4 } (char-downcase h i) h i 5 display write write-char > (write-char #\9) 9#<unspecified> > (write-char #\newline) #<unspecified> 4;5 h i h i h i
122 6 Scheme ( ) 2 } (list->string h i) h i } (string->list h i) h i > (list->string (list #\p #\o #\o #\h)) "pooh" > (list->string '()) "" > (string->list "owl") (#\o #\w #\l) 612 3 cdr 2 car 100 cdr (vector) car cdr ( cons ) 61 4 A, B, C, D i vector make-vector #( ) } (vector h 1 i h 2 i ) h 1 i h 2 i
61 ( 2) 123 (b) B D C A D() B C A (a) 61: } (make-vector n) ( ) n ( ) 4 (make-vector n h i) ( ) n h i make-vector > (vector 'pooh 'piglet 'tiger) #(pooh piglet tiger) > (vector 'pooh 'piglet '(kanga roo) 'tiger) #(pooh piglet (kanga roo) tiger) > (make-vector 3 'honey) #(honey honey honey) > (make-vector 3) #(#<unspecified> #<unspecified> #<unspecified>) } (vector-ref h i i) h i i } (vector-set! h i i h i) h i i h i } (vector-length h i) h i ( ) ( #() 0 )
124 6 Scheme ( ) 4 (vector-fill! h i h i) h i h i (index) : 0 h i (vector-ref h i 0) > (define v (vector 'pooh 'piglet 'tiger)) #<unspecified> > v #(pooh piglet tiger) > (vector-ref v 0) pooh > (vector-ref v 1) piglet > (vector-ref v 2) tiger > (vector-set! v 1 'rabbit) #<unspecified> > v #(pooh rabbit tiger) > (vector-length '#(alice hair hatter)) 3 > (vector-length '#(alice)) 1 > (vector-length '#()) 0 vector? } (vector? h i) h i #t #f > (vector? '#(alice cheshire-cat caterpiller)) #t > (vector? '(alice cheshire-cat caterpiller)) #f
61 ( 2) 125 : '#() ( ) > (define a '#(kanga roo)) #<unspecified> > a #(kanga roo) } (vector->list h i h i h i h i } (list->vector h i h i h i h i > (vector->list '#(mouse lory duck dodo)) (mouse lory duck dodo) > (list->vector '(mouse lory duck dodo)) #(mouse lory duck dodo) > (vector-ref (list->vector '(mouse lory duck dodo) 2)) duck 613 ( ) 362 (number) Scheme (integer) (rational) ( ) (real) (complex) 26 26 26 1 26:0 26 26:0+0:0i 1:5 1:5+0:0i 62 Scheme
126 6 Scheme ( ) 45:0+0:0i 45:0 3=4 45=1 45,23 1,31=5 3:1415 2:1, 3:0i 1:2+3:5i 1=2 1=3 0:5 3:33 3:1+4:7i 0:5+0:0i 3:33 + 0:0i 62: } (number? h i) h i #t #f } (integer? h i) h i #t #f } (rational? h i) h i #t #f } (real? h i) h i #t #f } (complex? h i) h i #t #f > (integer? 26) #t > (real? 26) #t > (complex? 26) #t > (integer? 15) #f > (real? 15) #t
61 ( 2) 127 > (complex? 15) #t Scheme ( ) Scheme 4 (rationalize x y) x x y 6 4 (numerator n) n n 4 (denominator n) n n n 0 1 4 (make-rectangular x y) x + yi (i ) 4 (make-polar r t) r e it (i ) 4 (real-part z ) z 4 (imag-part z ) z 4 (magnitude z ) z 4 (angle z ) z 10 314 10 16 7 16 #x 16 (x hexadecimal x ) 6 2 r1 = n1=d1 r2 = n2=d2 jn1j jn2j jd1j jd2j r1 r2 3=5 4=7 0 =0=1 2=7 2=5 7 10 0 9 10 16 0 9 a f 16 ( / ) 16 a 10 10 16 13 10 19 (= 1 16 + 3 1)
128 6 Scheme ( ) > #x10 16 10 (10 16) 16 10 > #x1f 31 2 (#b) 8 (#o) 10 (#d) > #b1011 2 1011 16 10 10 > #o71 8 71 57 10 57 > #d26 10 26 26 10 26 > 26 10 26 > (+ #b10 #o10 #d10 #x10) (+ 2 8 10 16) 36 0 0 0 0 Scheme 540e3 54:0 10 3 = 54000:0 1675e-5 167:5 10,5 =0:001675 MeE M 10 E (oatingpoint representation) 8 ( E ) M (mantissa) E (exponent) > (+ 320e2 11e3) 43e3 > (* 50e+10 2) 1000e9 > (* 10e64 31e10) 31e75 #e #i e exact ( ) i inexact ( ) 8 e s,f,d,l short, single, double, long e
61 ( 2) 129 #f > #e3 3 > #i3 30 > (inexact? #e3) #f > (inexact? #i3) #t } (number->string h i) h i } (string->number h i) h i > (string->number "300") 300 > (string->number "#x1f") 31 > (string->number "314e-1") 314 > (number->string 300) "300" > (number->string 6626e-34) "6626e-36" > (number->string (+ 1 2)) "3" string->number #f > (string->number "pooh") #f > (string->number "zero") #f
130 6 Scheme ( ) 614 ( ) 363 363 "Pooh loves honey" } (make-string k ) k } (make-string k h i) h i k ( k ) } (string h 1 i h 2 i ) h 1 i h 2 i ( ) s c 0 c 1 :::c n,1 c i Scheme 0 1 2 } (string-ref h i k ) h i k } (string-set! h i k h i) h i k h i k 0 k<(string-length h i) > (define s (make-string 8 #\x)) #<unspecified> > s "xxxxxxxx"
61 ( 2) 131 > (string-set! s 0 #\y) #<unspecified> > s "yxxxxxxx" > (string-ref s 0) #\y > (string-ref s 1) #\x 4 (string-copy h i) h i h i h i 4 (string-fill! h i h i) h i h i : (let ((name "pooh")) (string-set! name 1 #\w)) ( ) string-copy } (symbol->string h i) h i 9 } (string->symbol h i) h i 9 h i read h i string-symbol / string-symbol string-set!
132 6 Scheme ( ) 62 display Scheme 621 } (display h i) h i h i (") } (write h i) h i h i (") } (write-char h i) h i > (write 34) 34#<unspecified> > (write '(bear "Pooh")) (bear "Pooh")#<unspecified> > (write '(bear "Pooh")) (bear Pooh)#<unspecified> #<unspecified> write display #<unspecified> (34 ) (write display Scheme ) write display >(begin (display "Winnie-") (display "the-") (display "Pooh")) Winnie-the-Pooh#<unspecified>
62 133 } (newline) >(begin (display "Pooh") (newline) (display "Piglet")) Pooh Piglet#<unspecified> (newline) write-char (write-char #newline) 622 (input/output) ( ) 10 Pooh Owl P o o h #\newline O w l 10
134 6 Scheme ( ) 623 Scheme (port) Scheme (input port) (output port) 1 p 2 p ( p ) 3 p } (open-input-file h i) h i h i } (open-output-file h i) h i h i ( ) } (write h i h i) } (display h i h i) } (write-char h i h i) h i h i h i (current output port) } (close-input-port h i) h i
62 135 P o o h O w l p p p p 63: } (close-output-port h i) h i } (input-port? h i) h i #f #f } (output-port? h i) h i #f #f (current input port) (current output port) 11 } (current-input-port) } (current-output-port) 624 63 Pooh Owl 2 2 11
136 6 Scheme ( ) K a n g a & R o o p p p p (a) K a n g a & R o o p p p p (b) 1 64: Scheme 1 64 ( a ) 1 2 ; ( ) " " ( ) 65 ( )
62 137 ( A 5 ) p p p p p p (a) ( A 5 ) p p p p p p (b) ( A 5 ) p p p p p (c) ((A 5) ) p 65: } (read h i) h i (Scheme ) 1 } (read-char h i) h i 1 (endof-le object) read read-char } (eof-object? h i) h i #t #f } (peek-char h i) h i 1 4 (char-ready? h i) h i 1 #t #f
138 6 Scheme ( ) read-char read-char char-ready? 625 12 4 (call-with-input-file h i h i) h i h i h i h i h i h i 1 4 (call-with-output-file h i h i) h i h i h i h i h i h i 1 } (with-input-from-file h i h i) h i h i h i h i h i h i } (with-output-to-file h i h i) h i h i h i h i h i h i 12 call-with-input-file call-with-output-file Scheme
63 139 Scheme Scheme Scheme p (file-exists? h i) h i #t #f p (force-output h i) (flush-output-port h i) ( ) h i p (delete-file h i) h i p (rename-file h i h i) h i h i 63 : (define (foo n) (define (bar i) (* i i)) (list n (bar n))) foo bar ( ) (internal denition) (top level denition) foo > (define (bar) (+ i 1)) #<unspecified> > (foo 3) 9 > (bar 3) 4
140 6 Scheme ( ) (define (bar i) (+ i 1)) (define (foo n) (define (bar i) (* i i)) (bar n)) 66: 1 bar foo bar 66 foo (bar n) foo bar foo foo bar (foo 2)? (define (foo n) (define (bar n) (* n n)) (list (bar n) (qwe n))) (define (qwe n) (bar n)) (define (bar n) (+ n 1))
63 141 (define (foo n) (define (bar n) (* n n)) (list (bar n) (qwe n))) (define (qwe n) (bar n)) (define (bar n) (+ n 1)) 67: (2) (4 3) foo (list (bar n) (qwe n)) (bar n) 4 (qwe n) qwe (bar n) bar foo ( 1 ) (bar n) 3 foo bar foo 67 (lexical scoping) (binding) ( ) (static binding) ( ) (dynamic scoping) (dynamic binding) 13 13 Lisp (Lisp 15 MacLisp ) Scheme Lisp Common Lisp
142 6 Scheme ( ) ( ) v v f f n n 2 (define (f n) (define value (* n n)) (lambda () value)) f value f value > (define g2 (f 2)) #<unspecified> > (g2) 4 > (define g6 (f 6)) #<unspecified> > (g6) 36 > (g2) 4 f value f lambda value value f g2 g6 ( ) (environment)
64 ( 2) 143 g2 ( ) value 4 g6 ( ) 36 (lambda () value) 64 ( 2) 641 case if cond case > (case 'kennedy ((kennedy roosevelt lincoln) 'president) ((tanaka nakasone murayama) president 'prime-minister)) > (case 'murayama ((kennedy roosevelt lincoln) 'president) ((tanaka nakasone murayama) 'prime-minister)) prime-minister case cond case } (case h i h 1 i h 2 i h n i) h i ((h i ) h 1 i h 2 i ) h i else (else clause) else (else h 1 i h 2 i )
144 6 Scheme ( ) h i h i else case h i h i h i ( h i eqv? ) h i h i h i case h i h i case helse i helse i case helse i number->name (define (num->name n) (case n ((1) 'one) ((2) 'two) ((3) 'three) (else 'many))) > (num->name 1) one > (num->name 2) two > (num->name 3) three > (num->name 4) many > (num->name 5) many 642 let let let Scheme Scheme ( let letrec ) let let let let let
64 ( 2) 145 4 (let h i ((h 1 i h 1 i) h i) (h 2 i h 2 i) (h n i h n i)) let h i (let loop ((l '(a b c)) (n 0)) (if (null? l) n (loop (cdr l) (+ n 1)))) loop l n let l n (cdr l) (+ n 1) loop l n (a b c) 0 let (if ) let let (loop harg 1 i harg 2 i) harg 1 i harg 2 i let let l n (a b c) 0 l (loop (cdr l) (+ n 1)) l n (b c) 1 let l n let 3 (define (sum n) (let loop ((i n) (total 0)) (display (list i total)) (newline) (if (= i 0)
146 6 Scheme ( ) total (loop (- i 1) (+ total i))))) let n 1 n ( display, newline ) i n 1 total n i i 0 total 6 > (sum 5) (5 0) (4 5) (3 9) (2 12) (1 14) (0 15) 643 letrec letrec } (letrec ((h 1 i h 1 i) (h 2 i h 2 i) (h n i h n i)) h i) h i letrec let (define (sum n) (letrec ((loop (lambda (i total) (display (list i total)) (newline) (if (= i 0)
64 ( 2) 147 total (loop n 0))) (loop (- i 1) (+ total i)))))) let letrec lambda loop letrec (loop n 0) (lambda ) (lambda ) (loop ) loop let 2 (define (is-even-number? n) (letrec ((even? (lambda (n) (if (zero? n) #t (odd? (- n 1))))) (odd? (lambda (n) (if (zero? n) #f (even? (- n 1)))))) (even? n))) > (is-even-number? 4) #t > (is-even-number? 5) #f is-even-number? even? odd? (mutual recursion) letrec let let 68(b) let even? odd? let letrec letrec
148 6 Scheme ( ) (define (is-even-number? n) (letrec ( (even? (lambda (n) (if (zero? n) #t (odd? (- n 1))))) (odd? (even? n))) (lambda (n) (if (zero? n) #f (even? (- n 1))))) ) (a) letrec (define (is-even-number? n) (let ( (even? (even? n))) (b) let?????? (lambda (n) (if (zero? n) #t (odd? (- n 1))))) (odd? (lambda (n) (if (zero? n) #f (even? (- n 1))))) ) 68: letrec let 65 651 n (factorial) n! 1 n n! =n (n, 1) (n, 2) 2 1 ( 1 n =1 n! = n (n, 1)! n 2
65 149 ; procedure "factorial" ; --- computes factorial of n : n! = n (n-1) (n-2) 1 ; argument: n - integer (must be positive) (define (factorial n) (if (= n 1) 1 (* n (factorial (- n 1))))) (a) ;; purocedure f (define (f x) (if (= x 1) 1 (* x (f (- x 1))))) (b) 69: 2 651(b) (c) 651(a) (b) f (indent) 651(a) F i = 8 >< >: 1 n =1 1 n =2 F i,1 + F i,2 n 3 651(a),(b) n 651(b)
150 6 Scheme ( ) ; compute n-th Fibonacci (define (fibonacci n) (if (= n 1) 1 (if (= n 2) 1 (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))) (a) ; compute n-th Fibonacci (define (fibonacci n) (if (= n 1) 1 (if (= n 2) 1 (+ (fibonacci (- n 2)) (fibonacci (- n 1)))))) (b) 610: 14 Scheme 80 1 80 define 2 (define (h i h i) h i) 14
65 151 (define h i h i) h i (define h i h i) if if 2 (if h i h 1 i) (if h i h 1 i) h 2 i) cond cond (cond (h 1 i h i ) (h n i h i )) h i (cond (h 1 i h i ) (h n i h i )) let
152 6 Scheme ( ) (let ((h 1 i h 1 i) h 1 i h n i) (h n i h n i)) (let ((h 1 i h 1 i h n i) h 1 i) (h n i h n i)) (let ((h 1 i h 1 i) (h n i h n i)) h 1 i h n i) (h i h i h i) h i (h i h i h i h i h i h i h i)
65 153 (h i h i h i h i h i h i h i) h i 652 651 3 (a),(b),(c) 651(a) b, c (a) (b) (a) (b) S S (c) b c? 651(c) ( )
154 6 Scheme ( ) ;; SYOUHIZEI (define (S b c) (if (null? b) 0 (+ (* c (car b)) (S (cdr b) c)))) (a) 1 ;; procedure "S" ;; - computes SYOUHIZEI ;; argument: b - list of price ;; c - tax rate (define (S b c) (if (null? b) 0 (+ (* c (car b)) (S (cdr b) c)))) (b) 2 ;; procedure "SyouhiZei" ;; - computes sum of SYOUHIZEI of each item ;; argument: list-of-price - list of price (eg ) ;; tax-rate - tax rate (eg be 003) ;; Example: ;; (SyouhiZei '(1000 200 800) 003) ;; ---> 60 = 003*1000+003*200+003*800 ;; (define (SyouhiZei list-of-price tax-rate) (if (null? list-of-price) 0 (+ (* tax-rate (car list-of-price)) (SyouhiZei (cdr list-of-price) tax-rate)))) (c) 611:
65 155 B W Kernighan, P J Plauger ( ), \ ",,, 1982 B W Kernighan, P J Plauger ( ), \ ",, 1981 F P Brooks Jr ( ), \ ",, 1977 D E Knuth ( ), \ ",, 1994,\ ",, 1985
156 6 Scheme ( )
7 NGSCM NGSCM NGSCM NGSCM 71 NGSCM 711 NGSCM a a NGSCM b 1 2 1 1 (controle key) (shift key) (tab key) `CTL' `CTRL' `Control' 2 (escape key) ( `ESC' ) 157
158 7 NGSCM This is an Eample (a) x This is an Example (b) 71: u C-k k M-k k C-x k C-x k C-c k C-c k M-x command-name x command-name RET ( ) 712 71 Eample a x Example a 3 Emacs / Emacs (meta key) 3 Emacs (point)
71 NGSCM 159 C-b 1 C-f 1 C-n C-p RET M-b 1 M-f 1 C-a C-e C-v 1 M-v 1 M-< M-> C-l
160 7 NGSCM 713 (mark) C- SPC C-@ M-x set-mark-command C-x C-x C-x C-x C-x C-x 2 (region) 714 (delete) (kill) (kill buer) C-d 1
71 NGSCM 161 "But what happens when you come to the beginning again?" Alice ventured to ask "Exactly so," said the Hatter: "as the things get used up" "Suppose we change the subject," the march Hare interrupted yawning (a) "Exactly so," said the Hatter: "as the things get used up" "Suppose we change the subject," the march Hare interrupted yawning (b) 4 C-k ("But what to ask 2 ) "Exactly so," said the Hatter: "as the things get used up" "But what happens when you come to the beginning again?" Alice ventured to ask "Suppose we change the subject," the march Hare interrupted yawning (c) "Suppose C-y 72: (LCarroll \Alice's Adventures in Wonderland" )
162 7 NGSCM DEL 1 C-k M-d C-w M-w (yank) C-y C-k M-d 4 ( ) C-k C-y 4 C-k 72 C-w (cut and paste) C-SPC C-w C-y C-y C-w M-w
71 NGSCM 163 715 C-x C-f C-x C-r ( C-x C-q ) C-x i C-x C-s C-x C-w C-x C-f Find file: : C-g :
164 7 NGSCM 4 factscm<2> factscm<3> :: NGSCM n 716 (completion) M-x sumscm C-x C-f sumscm sumscm s sumscm C-x C-f s TAB Find file: s TAB qwescm Find file: sumscm s sumscm sum1scm s TAB sum s sum sum 73 *Completion* sum 1 ( sum1 ) TAB Find file: sum1 TAB sum1 sum1scm sum1scm Find file: sum1scm 4
71 NGSCM 165 SCM version 4e1, Copyright (C) 1990, 1991, 1992, 1993, 1994 Aubrey Jaffer SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)' This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details ;loading "/usr/local/lib/scm/transcenscm" ;done loading "/usr/local/lib/scm/transcenscm" ;Evaluation took 105 msec (0 in gc) 9993 cells work, 12800 bytes other > --**-NGSCM: *scheme* Possible completions are: sumscm sum1scm (-EE:fundamental-Scheme Interaction)-- -----NGSCM: *Completions* Find file: sum (-EE:fundamental)--------------------- 73: s RET Find file: s TAB Find file: s [No match] 717 (search) (replace) (regular expression) C-s C-r
166 7 NGSCM M-x search-forward M-x search-backword M-% define C-s I-search: define d d ESC e de I-search: de d, e, f, i, n, e BS DEL define ESC C-s C-s 2 C-s C-r (C-s ) M-x search-formard, M-x search-backword Search: RET
71 NGSCM 167 Search: define RET Search failed: "define" : C-g M-% Eeyore Rabbit M-% Query replace: Eeyore RET Query replace: Eeyore with: Rabbit RET Query replaceing Eeyore with Rabbit: SPC DEL! ESC Mule y n! NGSCM q
168 7 NGSCM MR Buffer Size File -- ------ ---- ---- *help* 3571 *Buffer List* 0 * *scheme* 529 % qwescm 143 /tmp_mnt/condor/home1/kakugawa/qwescm *scratch* 0 -----NGSCM: *Buffer List* (-EE:fundamental)--------------------- 74: 718 C-x C-b *Buffer List* 74 ( ) * % (C-x C-r ) C-x b C-x b Switch to buffer: (default buer) RET buer RET
71 NGSCM 169 RET Switch to buffer: (default *scratch*) fscm RET fscm C-x k C-x C-q / C-x k Kill buffer: (default buer) buer RET buer RET ( ) Kill buffer: (default *scheme*) fscm RET fscm ( ) : Buffer modifed; kill anyway? (yes or no)
170 7 NGSCM C-x C-q --**-NGSCM --%%-NGSCM C-x C-q --%%-NGSCM 719 (multiple windows) 43 2 2 qwescm *scheme* (window) 2 ( ) C-x 2 2 C-x 0 C-x 1 75 C-x 2 76 2 76 factscm 77
71 NGSCM 171 (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) -----NGSCM: sumscm (-EE:fundamental-Scheme)-------------- 75: 1 C-x o C-x^ M-x shrink-window C-x o C-x^ 1 M-x shrink-window 1 77 2 25 ( ) C-x^ 78 5 C-x^
172 7 NGSCM (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) -----NGSCM: sumscm (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) (-EE:fundamental-Scheme)-------------- -----NGSCM: sumscm (-EE:fundamental-Scheme)-------------- 76: 2 ;; ;; fact ;; (define (fact n) (define (fact2 n f) (if (= n 1) f (fact2 (- n 1) (* n f)))) (fact2 n 1)) -----NGSCM: factscm (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) (-EE:fundamental-Scheme)-------------- -----NGSCM: sumscm (Read 9 lines) (-EE:fundamental-Scheme)-------------- 77:, factscm
71 NGSCM 173 ;; ;; fact ;; (define (fact n) (define (fact2 n f) (if (= n 1) f (fact2 (- n 1) (* n f)))) (fact2 n 1)) -----NGSCM: qwescm (if (= n 1) 1 (+ (sum (- n 1)) n))) (-EE:fundamental-Scheme)-------------- -----NGSCM: sumscm (-EE:fundamental-Scheme)-------------- 78: N Meyrowitz, A van Dam ( ), \ : I ", bit, pp75{104,, 1983 (N Meyrowitz, A van Dam, \Interactive Editing Systems: Part I", ACM Computing Surveys, Vol 14 No 3, pp321{352, September 1982) N Meyrowitz, A van Dam ( ), \ : II ", bit, p105{166,, 1983 (N Meyrowitz, A van Dam, \Interactive Editing Systems: Part II", ACM Computing Surveys, Vol 14 No 3, pp353{415, September 1982), ( ), \ ",, 25 8, p758{874,, 1984 8 Richard M Stallman (, ), \GNU Emacs ",, 1988 2 Craig A Finseth ( ), \The Craft of Text Editing { {",, 1994 4
174 7 NGSCM 1 3 a; b; x ax + b fx (define (fx a b x) (+ (* a x) b)) fxscm > (fx 2 3 4) ;Evaluation took 16 msec (0 in gc) 5 cons work 11 > (fx 2 3 8) ;Evaluation took 0 msec (0 in gc) 5 cons work 19 2 power powerscm 2 a; b a b (define (power a b) (if (= b 0) 1 (* a (power a (- b 1))))) > (power 2 3) ;Evaluation took 0 msec (0 in gc) 18 cons work 8 > (power 2 6) ;Evaluation took 0 msec (0 in gc) 28 cons work 64 3 ave avescm 3 (define (ave a1 a2 a3) (/ (+ a1 a2 a3) 3))
71 NGSCM 175 > (ave 2 3 4) ;Evaluation took 0 msec (0 in gc) 8 cons work 3 > (power 4 5 12) ;Evaluation took 0 msec (0 in gc) 8 cons work 7
176 7 NGSCM
8 Scheme NGSCM Scheme Scheme 44 NGSCM Scheme Scheme NGSCM Scheme NGSCM Mule Mule 81 Scheme Scheme Interaction Scheme Scheme (mode) 7 fundermental 1 Scheme Scheme 7 NGSCM fundamental scm 1 GNU Emacs Mule Fundermental 177
178 8 Scheme Scheme 44 scm s Scheme Scheme Scheme Scheme M-x scheme-mode -----NGSCM: sums (-EE:fundamental)--------------------- -----NGSCM: sums (-EE:fundamental-Scheme)-------------- fundermental Scheme Scheme Interaction Scheme Scheme Scheme Interaction Scheme Interaction --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- *scheme* Scheme Scheme 2 Scheme Scheme Scheme M-x scheme-mode Scheme scm Scheme C-j, C-c C-e Scheme (*scheme*) (C-j Scheme Interaction ) 2 Scheme Scheme Interaction Scheme Interaction *scheme*
81 Scheme Scheme Interaction 179 M-ESC Scheme CtlcC-r Scheme C-M-f C-M-b C-M-k TAB LFD RET TAB Defun Scheme Scheme (top level) defun 3 defun C-M-a defun defun C-M-e defun defun 3 Lisp defun (defun )
180 8 Scheme C-M-h defun defun C-M-a (define C-M-a defun 811 *scheme* NGSCM (history) M-p 1 M-n 1 NGSCM (list 1 2 3 4 5) (+ 1 2 3 4 5) (* 1 2 3 4 5) (vector 1 2 3 4 5) 81 M-p ( (vector 1 2 3 4 5) M-p ( (* 1 2 3 4 5) ) M-p M-p M-n 82
81 Scheme Scheme Interaction 181 Bug reports, suggestions, requests are welcome Send E-Mail to kakugawa@sehiroshima-uacjp > (list 1 2 3 4 5) (1 2 3 4 5) > (+ 1 2 3 4 5) 15 > (* 1 2 3 4 5) 120 > (vector 1 2 3 4 5) #(1 2 3 4 5) > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 81: C-j C-j : NGSCM *scheme* > ( ) 2 1 *scheme* M-p ( *scheme* ) 5 M-p (vector 1 2 3 4 5) M-n
182 8 Scheme > (vector 1 2 3 4 5) (1) 1 M-C-p > (* 1 2 3 4 5) (2) M-C-p > (list 1 2 3 4 5) (3) 2 M-C-p > (+ 1 2 3 4 5) (4) M-C-n 82: C-c C-p 1 C-c C-n 1 812 NGSCM Scheme NGSCM Scheme 1 :
ppppppppp ppppppppp 81 Scheme Scheme Interaction 183 p p p p p p p p p p (define (qweqwe n) (+ n n n)) p p p p p p p p p p ppppp p p p p p p p ppppppp pppppppppp > (define (qweqwe n) (+ n n n)) #<unspecified> > (qweqwe 10) 30 > Scheme *scheme* p p pp p pp p p p p p p pp ppp NGSCM 83: NGSCM Scheme NGSCM Mule GNU Emacs Scheme Mule Scheme Scheme ( ) Scheme C-c C-e C-j S- *scheme* 83 NGSCM Scheme *scheme* C-c C-e C-j Scheme Scheme ( ) *scheme* ( ) C-c C-e, *scheme* *scheme* *scheme* Scheme Scheme *scheme* Scheme
184 8 Scheme Interaction
9 2 5 1 1 1 Scheme 2 3 30 2 4 2: 185
186 9 2 91 ( ) ( ) (message) ( ) 911 (define (make-wallet money) (lambda (amount) (if (< money amount) "Not enough money" (begin (set! money (- money amount)) money)))) make-wallet money (make-wallet 100) (lambda (amount) ) (make-wallet 100) ( make-wallet ) (lambda (amount) ) 1
91 187 > (define w (make-wallet 100)) #<unspecified> > (w 10) 90 > (w 10) 80 > (w 10) 70 money w money w ( 63 ) > (define money 10000) #<unspecified> > (define w (make-wallet 100)) #<unspecified> > (w 10) 90 > (w 10) 80 > money 10000 w money w amount money money 2 (w 10) (set! money (- money amount)) (w 10) money ( ) ( 91 ) w (lambda (amount) (if (< money amount) "Not enough money" (begin (set! money (- money amount)) money)))
188 9 2 > (w 10) q W money: 100 (lambda (amount) (if (< money ) 91: money money make-wallet (lambda (amonut) ) make-wallet w set! money make-wallet make-wallet 1 money make-wallet (make-wallet 100) money (make-wallet 100) money > (define w1 (make-wallet 100)) #<unspecified> > (define w2 (make-wallet 100)) #<unspecified> > (w1 20) 80 > (w2 10) 90 1 (make-wallet 100) money 100 (lambda (amount) ) ((lambda (amount) )) make-wallet
91 189 > (w1 40) 40 912 (vending machine) 1 1 ( ) ( ) ( ) ( ) : (define (new-vend stock) (lambda message (cond (h button i h i ) (hstock i h i) (h, i ))))
190 9 2 new-vend stock (define (new-vend stock) (lambda message (cond ((eq? (car message) 'button) (if (= stock 0) "Sold out" (begin (set! stock (- stock 1)) 'juice))) ((eq? (car message) 'stock) stock) (else (error "Unknown message" message))))) (lambda messages ) message ( (message) message ) message ( message 1 ) button ( (= stock 0) ) "Sold out" 1 stock (stock ) 2 > (define v (new-vend 2)) 2 #<unspecified> > (v 'button) 1 juice > (v 'stock)? 1 > (v 'button) 1 juice > (v 'button) "Sold out"
pppppppp pppppp 91 191 stock stock ppppppppppppppppppppppppppppppppppp p pppppppppp new-vend car cdr cons list button 92: 913 (v 'button) ( (buy-juice v)) ( ) ( ) (buy-juice v) (buy2-juice v2) ( 92 )
192 9 2 1 h???i accumulate (define (accumulate) (define h???i '()) (define new-obj (lambda (d) (h???i s (cons d s)) s)) new-obj) > (define a (accumulate)) #<unspecified> > (a 'pen) (pen) > (a 'a) (a pen) > (a 'is) (is a pen) > (a 'this) (this is a pen) 2 make-wallet (define (make-wallet-2 money amount) (if (< money amount) "Not enough money" (begin (set! money (- money amount)) money))) make-wallet make-wallet 3 new-vend new-vend2 h???i
91 193 (define (new-vend2 stock) (define (button-msg) h???i) (define (stock-msg) h???i) (lambda message (cond ((eq? (car message) 'button) h???i) ((eq? (car message) 'stock) (stock-msg)) (else (error "Unknown message" message))))) 4 new-vend 1 5 5 new-vend (!) vend supply (v 'supply 10) v 10 6 7 * 1 1
194 9 2
92 195 92 ( ) 2 (le name) ( ) 62 921 show-s-exp 62 (define (show-s-exp filename) hfilename port i hport exp i hexp i hexp i hport exp i hport i ) filename open-input-file (define (show-s-exp filename) (let ((port (open-input-file filename))) (letrec ((loop 2 MS-DOS PRN
196 9 2 (lambda (exp) (if (eof-object? exp) 'done (begin (write exp) (newline) (loop (read port))))))) (loop (read port))) (close-input-port port))) letrec letrec exp loop (loop (read port)) loop exp letrec done ( ) exp (loop (read port)) loop letrec (close-input-port port) show-s-exp testdatascm ( ) (a b c) 123 111 a b c d "STRING!!" ; a comment line end? (show-s-exp "testdatascm") > (show-s-exp "testdatascm") (a b c) 123 111 a b
92 197 c d "STRING!!" end? #<unspecified> 1 1 sum-file (define (sum-file filename) hfilename port i h total 0 i hport exp i hexp :i htotal exp i hport exp i hport i htotal i ) sum-file (define (sum-file filename) (let ((port (open-input-file filename)) (total 0)) (letrec ((loop (lambda (exp) (if (eof-object? exp) 'done (begin (set! total (+ total exp)) (loop (read port))))))) (loop (read port))) (close-input-port port)
198 9 2 total)) total total sum-file total 3 numdatascm : 89 78 12 45 60 92 100 88 sum-file > (num-file "numdatascm") 564 922 1 Scheme outscm out-list (define (out-list s) (let ((port (open-output-file "outscm"))) (do ((rest s (cdr rest))) ((null? rest)) (write (car rest) port) (newline port)) (close-output-port port))) open-output-file write newline > (out-list '(a b 200 (foo bar baz) ((0 1 2) (3 4 5)))) #<unspecified> outscm 3 let total
92 199 a b 200 (foo bar baz) ((0 1 2) (3 4 5)) 923 `A' `Z' read-char write-char count-lines (return character) #\newline #\nl (define (count-lines filename) hfilename port i h lines 0 i hport ch 1 i hch i h ch lines 1 i hport ch 1 i hport i hlines i ) (define (count-lines filename) (let ((port (open-input-file filename))
200 9 2 (letrec (lines 0)) ((loop (lambda (ch) (cond ((eof-object? ch) (close-input-port port) lines) ((equal? ch #\newline) (set! lines (+ lines 1)) (loop (read-char port))) (else (loop (read-char port))))))) (loop (read-char port))))) > (count-lines "testdatascm") 8 > (count-lines "numdatascm") 2 to-upper (define (to-upper infile outfile) hinfile inport i houtfile outport i hinport ch 1 i hch i h ch ch outport i h ch outport i hinport ch 1 i hinport outport i ) 4 4 char-upcase char-lower-case?
92 201 (define (to-upper infile outfile) (let ((inport (open-input-file infile)) (outport (open-output-file outfile))) (letrec ((loop (lambda (ch) (cond ((eof-object? ch) (close-input-port inport) (close-output-port outport)) ((char-lower-case? ch) (write-char (char-upcase ch) outport) (loop (read-char inport))) (else (write-char ch outport) (loop (read-char inport))))))) (loop (read-char inport))))) testfile : This is the TEST file to-upper > (to-upper "testfile" "out") done out testfile : THIS IS THE TEST FILE 1 count-s-exp 2 count-symbol
202 9 2 3 count-occur (count-occur ) equal? 4 count-char ( ) 5 count-word (#\space) (#\tab) (#\newline) 6 `A' `Z' count-freq 7 Scheme get-define 8 * 1 (a-word/line ) 9 * Scheme symbols-in-file 10 * ( ) 1 1 ( ) (test-score ) ( )
92 203 ("Tanaka Misako" 98 68 84) ("Nishida Hikaru" 98 100 76) ("Takahashi Yumiko" 50 72 82) ("Takata Mayuko" 97 67 78) ("Yoshida Mayuko" 68 80 79) ("Yoshida Makiko" 86 99 77) ("Amuro Namie" 69 89 98) ("Uchida Yuki" 71 89 70) 11 * 1 2 10?
204 9 2 93 ( ) (sorting) ( ) 100 100 (`system' `a' `r' ) (bubble sort) (quick sort) 2 931 : 1 2 3 1 2 2 2 3 i a i i a i a i+1 a i <a i+1 i i
93 205 5 i a i a i+1 ( ) (algorithm) 6 ( ) (selection sort) ( (straight selection sort)) (bubble sort) 2 2 2 3 2 Scheme bubble-sort! 7 (define (bubble-sort! numbers) h i (0 hnumebrs -2i) i h j (i+1 hnumebrs -1i) i h j i i h i ) Scheme 5 6 7 set! vector-set!! Scheme ( )!
206 9 2 (define (bubble-sort! numbers) (do ((i 0 (+ i 1)) (swap #f)) i j ((= i (- (vector-length numbers) 1)) numbers) (do ((j (+ i 1) (+ j 1))) ((= j (vector-length numbers))) (if (< (vector-ref numbers i) (vector-ref numbers j)) (begin i j (set! swap (vector-ref numbers j)) (vector-set! numbers j (vector-ref numbers i)) (vector-set! numbers i swap)))))) i j swap > (bubble-sort! (vector 2 3 43 2 1 5 0)) #(43 4 3 2 2 1 0) > (bubble-sort! (vector 1 2)) #(2 1) > (bubble-sort! (vector 100)) #(100) 932 (quick sort) 1 2 2 3 4 5
93 207 p p p p p pp p p p p ppppppppp p p p ppppppppp p p p p p p p p q p p p ppppppp p p pp ppppp p p p p p p p p p p p p p p p p p p p p p p p p p p p 93: 93 2 2 ( 1) ( 2 2 ) ( ) 2 (devide and conquer) partition! ( ) partition! (partition! v x y) v x y 2 (partition! v x y) z
208 9 2 v z z v z v z p p p p p p p p p p p p v 94: partition! v z partition! v x z, 1 v z +1 y : i (x i z, 1) (vector-ref v i) (vector-ref v z) i (z +1 i y) (vector-ref v z) (vector-ref v i) 94 partition! (define (quick-sort! vec) ; sub-sort! ; v x y (define (sub-sort! x y) (if (< x y) (let ((z (partition! vec x y))) (sub-sort! x (- z 1)) (sub-sort! (+ z 1) y)))) ; quick-sort! : ; sub-sort! 0 (sub-sort! 0 (- (vector-length vec) 1)) vec) quick-sort! sub-sort! sub-sort! 2 2 1
93 209 (a) x t p p p p p p t p t? p p p p p p (c) x t? p p p p p p t (d) x p p p p p p p p p t t (b) i t x p t t t p t i t p i i t? p p p p p p y y y y i 95: quick-sort! (sub-sort! 0 (- (vector-length vec) 1)) sub-sort! sub-sort! vec vec sub-sort! vec quick-sort! vec partition! 2 1 partition! 1 x t 2 p x 3 iy : i 1 i t p+1 i
210 9 2 p 1 4 x p 5 p x p t p i t x p 94 partition! (loop invariant) 95 Scheme (define (partition! vec x y) (let ((t (vector-ref vec x))) t ; (define (swap i j) i j (let ((temp (vector-ref vec i))) (vector-set! vec i (vector-ref vec j)) (vector-set! vec j temp))) ; (define (loop i p) (if (< y i) (begin (swap p x) p) (if (> (vector-ref vec i) t) (begin (swap (+ p 1) i) (loop (+ i 1) (+ p 1))) (loop (+ i 1) p)))) ; (loop (+ x 1) x))) partition!
93 211 > (define qweqwe (vector 7 4 9 10 3 4 12 3 33 1 0 2)) #<unspecified> > qweqwe #(7 4 9 10 3 4 12 3 33 1 0 2) > (partition! qweqwe 0 11) 4 > qweqwe #(33 9 10 12 7 4 4 3 3 1 0 2) partition! 4 4 7 0 3 33, 9, 10, 12 4+1 11 4, 4, 3, 3, 1, 0, 2 quick-sort! > (quick-sort! (vector 7 4 9 10 3 4 12 3 33 1 0 2)) #(33 12 10 9 7 4 4 3 3 2 1 0) > (quick-sort! (vector 8 4 6 1 10 3 44 11 1 1 1)) #(44 11 10 8 6 4 3 1 1 1 1) 933 1 3 make-randam-vector n 8 2 make-random 8 (random number) (pseudo random number)
212 9 2 ; n (define (make-random-vector n random-obj) (do ((rv (make-vector n)) (i 0 (+ i 1))) ((= i n) rv) (vector-set! rv i (inexact->exact (floor (* (random-obj) 1000)))))) ; (define (make-random) (define seed 1) (define (obj) (let* ((hi (truncate (/ seed 1277730))) (lo (- seed (* 1277730 hi))) (test (- (* 168070 lo) (* 28360 hi)))) (if (> test 00) (set! seed test) (set! seed (+ test 21474836470))) (/ seed 21474836470))) obj) \ ", (, bit, Vol25 No4,, 1993 4 ) 0 1 make-random-vector 0 999 > (define rand (make-random) #<unspecified> > (make-random-vector 10 rand) #(0 131 755 458 532 218 47 678 679 934) > (make-random-vector 10 rand) #(383 519 830 34 53 529 671 7 383 66) 2 test-sort 1 2 size 3 times 1
93 213 (define *rand* (make-random)) (define (test-sort times sorting-method size) (define (get-time) (/ (get-internal-run-time) internal-time-units-per-second)) (do ((start (get-time)) (i 1 (+ i 1))) ((> i times) (inexact->exact (* 1000 (/ (- (get-time) start) times)))) (sorting-method (make-random-vector size *rand*)))) get-internal-run-time internal-time-units- 1 Scheme SCM Scheme > (test-sort 10 bubble-sort! 10) 500 > (test-sort 10 quick-sort! 10) 317 10 10 500 317 ( ) 96 Sun SPARC Station ELC ( 24MByte, SunOS 413) SCM 4c4 ( ) n n 0 n, 2 i j i +1 n, 1 i j
214 9 2 ( ) 3500 3000 2500 2000 1500 1000 500 0 b b b b b b b b b b b b b 0 50 100 150 200 250 300 96: (10 ) n,2 X n,1 X i=0 j=i+1 1 = n,2 X i=0 (n, i, 1) = n(n, 1)=2 2 2 2 n 2 n 2 n T (n) T (n) = h i +h i + h i = h i +2h n=2 i = hn i +2T (n=2) T (n) T (n) n log 2 n
93 215 9 n log 2 n 2 1 n, 1 2 n log 2 n n 2 1 2 3 string-sort! 4 absolute-sort! 5 (x y) 2 num2-sort! x 1 <x 2 (x 1 = x 2 y 1 <y 2 ) (x 1 y 1 ) < (x 2 y 2 ) (7 4)<(11 0) (1 2)<(1 3) 6 3 5 7 * 8 n An 2 Bn log 2 n A B 96 A B A B 1 10 100? 9 9 log 2 n 2 n 2 d = n d = log 2 n
216 9 2 10 Scheme selection-sort! 11 12 * n n 13 file-sort! (file-sort! inle outle) inle 195 22 89 123 345 1 345 195 123 89 22 14 * 92 10 1 2 n log n
93 217, \ ",, 1989 S K Park, K W Miller, ( ), \ ", bit, Vol25 No4, pp 19{27,, 1993 4, Vol25 No7, pp12{20, 1993 5
218 9 2 94 2: 53 53 941 k ( h i h i ) S read ADDRESSDAT ( 53 ) ;; DATA FILE FOR ADDRESS BOOK ; NAME PHONE NO (Chisato 012-345-6789 ) (Narimi 98-7654 ) (Mayuko 12-3456 ) (Misako 999-9999 ) ; end ; read Scheme 53 53 942 53
94 2: 219 (address-book) (add-to-address-book h i h i) (open-address-book) (close-address-book) (lookup-address) (next-address) (read-address) (end-of-address-book?) ADDRESSDAT
220 9 2 943 *ADDRESS-BOOK-FILE* ;;;---------------------------------------------------------------- ;;; (define *ADDRESS-BOOK-FILE* "ADDRESSDAT") 3 *ADDRESS-BOOK-PORT* *ADDRESS-BOOK-DATA* *ADDRESS-BOOK-OPENED* #t #f ;;;---------------------------------------------------------------- ;;; ( ) (define *ADDRESS-BOOK-PORT* #f) ; (define *ADDRESS-BOOK-DATA* #f) ; (define *ADDRESS-BOOK-OPENED* #f) ; read-data-item read S *ADDRESS-BOOK-DATA* ;;; (define (read-data-item) (set! *ADDRESS-BOOK-DATA* (read *ADDRESS-BOOK-PORT*))) open-address-book *ADDRESS-BOOK-OPENED* #f
94 2: 221 *ADDRESS-BOOK-PORT* *ADDRESS-BOOK-OPENED* #t *ADDRESS-BOOK-DATA* ; (define (open-address-book) (set! *ADDRESS-BOOK-OPENED* #f) (set! *ADDRESS-BOOK-PORT* (open-input-file *ADDRESS-BOOK-FILE*)) (set! *ADDRESS-BOOK-OPENED* #t) (set! *ADDRESS-BOOK-DATA* (read-data-item)) #t) ; (define (close-address-book) (if *ADDRESS-BOOK-OPENED* (close-input-port *ADDRESS-BOOK-PORT*) (error:not-opened)) (set! *ADDRESS-BOOK-OPENED* #f) #t) read-address *ADDRESS-BOOK-DATA* *ADDRESS-BOOK-DATA* *ADDRESS-BOOK-DATA* value *ADDRESS-BOOK-DATA* value ( ) ; ( ) (define (read-address) (if (not *ADDRESS-BOOK-OPENED*) (error:not-opened) (begin (let ((data *ADDRESS-BOOK-DATA*)) (set! *ADDRESS-BOOK-DATA* (read-data-item)) data))))
222 9 2 lookup-address *ADDRESS-BOOK-DATA* ( ) ; ( ) (define (lookup-address) (if *ADDRESS-BOOK-OPENED* *ADDRESS-BOOK-DATA* (error:not-opened))) next-address read-address *ADDRESS-BOOK-DATA* read-address ; (define (next-address) (read-address)) end-of-address-book? *ADDRESS-BOOK-DATA* read *ADDRESS-BOOK-DATA* ; (define (end-of-address-book?) (if *ADDRESS-BOOK-OPENED* (eof-object? *ADDRESS-BOOK-DATA*) (error:not-opened))) (error:opened, error:not-opened, make-address-item, get-name, get-phone) 53 944 ;;; ;;; addressscm ( FILE VERSION) ;;;
94 2: 223 ;;;---------------------------------------------------------------- ;;; (define *ADDRESS-BOOK-FILE* "ADDRESSDAT") ;;;---------------------------------------------------------------- ;;; ( ) (define *ADDRESS-BOOK-PORT* #f) ; (define *ADDRESS-BOOK-DATA* #f) ; (define *ADDRESS-BOOK-OPENED* #f) ; ;;;---------------------------------------------------------------- ;;; ( ) ; (define (open-address-book) (set! *ADDRESS-BOOK-OPENED* #f) (set! *ADDRESS-BOOK-PORT* (open-input-file *ADDRESS-BOOK-FILE*)) (set! *ADDRESS-BOOK-OPENED* #t) (set! *ADDRESS-BOOK-DATA* (read-data-item)) #t) ; (define (close-address-book) (if *ADDRESS-BOOK-OPENED* (close-input-port *ADDRESS-BOOK-PORT*) (error:not-opened)) (set! *ADDRESS-BOOK-OPENED* #f) #t) ; ( ) (define (read-address) (if (not *ADDRESS-BOOK-OPENED*) (error:not-opened) (begin (let ((data *ADDRESS-BOOK-DATA*)) (set! *ADDRESS-BOOK-DATA* (read-data-item)) data)))) ; ( ) (define (lookup-address) (if *ADDRESS-BOOK-OPENED* *ADDRESS-BOOK-DATA* (error:not-opened))) ; (define (next-address)
224 9 2 (read-address)) ; (define (end-of-address-book?) (if *ADDRESS-BOOK-OPENED* (eof-object? *ADDRESS-BOOK-DATA*) (error:not-opened))) ;;;---------------------------------------------------------------- ;;; ( ) ; (define (error:opened) (error "Already opened")) (define (error:not-opened) (error "Not opened")) ;;; ; (define (make-address-item name phone) (list name phone)) ; (define (get-name item) (car item)) ; (define (get-phone item) (cadr item)) ;;; (define (read-data-item) (set! *ADDRESS-BOOK-DATA* (read *ADDRESS-BOOK-PORT*))) ;end 945 53 53 phone (define (phone name) (let ((phone-number #f)) (open-address-book) (set! phone-number (search-phone name))
94 2: 225 (close-address-book) phone-number)) (define (search-phone name) (if (end-of-address-book?)? "Not found" "Not Found" (let ((item (read-address))) (if (equal? name (get-name item)) (get-phone item) (search-phone name))))) > (phone 'Chisato)? 012-345-6789 > (phone 'Mayuko)? 12-3456 > (phone 'Ayako)? "Not found" > (phone 'Misako)? 999-9999 946 1 ( ) Scheme
226 9 2 2 3 53 4 ** open-address-book 5 * 6 ** ( FORMAT-1) FORMAT-1 FORMAT-1 7 *** ( ) ( ) 8 **
94 2: 227 9
228 9 2
10 Scheme ( ) 101 ( 3) 1011 do do 1 f n P n i=1 i2 (define (f n) (do ((i 0 (+ i 1)) (the-sum 0)) ((> i n) the-sum) (set! the-sum (+ the-sum (* i i))))) 2 i the-sum 0 (> i n) (<= i n) do (set! the-sum (+ the-sum (* i i))) i (+ i 1) (the-sum ) (> i n) the-sum do do 4 (do ((h 1 i h 1 i h 1 i) (h n i h n i h n i)) (h i h 1 i h n i) h 1 i h n i ) 1 do Scheme 229
230 10 Scheme ( ) h 1 ih n i do h i i h i i h i #f h 1 i h n i h 1 i h 1 i h i #f h 1 i h i #f h 1 ih n i h n i do h i i, h i i, h i f the-sum h i sum-of-list (define (sum-of-list s) (do ((the-sum 0) (rest s (cdr rest))) ((null? rest) the-sum) (set! the-sum (+ the-sum (car rest)))) ) > (sum-of-list '(1 2 3 4)) 10 > (sum-of-list '(2 3)) 5 > (sum-of-list '()) 0 1012 for-each do for-each for-each > (define (proc s) (display s) (newline)) #<unspecified> > (for-each proc '(a b c)) a b c
101 ( 3) 231 (a b c) proc ( ) (begin (proc 'a) (proc 'b) (proc 'c)) for-each } (for-each h i h 1 i h 2 i h n i ) h i n 2 h i h 1 i h 2 i h n i 1 h i h 1 ih 2 i h n i 2 h i (let ((v 0)) (for-each (lambda (n) (set! v (+ v n))) '(1 3 5 7 9)) v) v (1 3 5 7 9) (lambda (n) (set! v (+ v n)) v v 25 for-each h i (side eect) v set! v for-each h i 2 n +
232 10 Scheme ( ) (let ((v 0)) (for-each (lambda (a b) (set! v (+ v (* a b)))) '(10 20 30) '(1 2 3)) v) 10 1+20 2+30 3 140 1013 map map > (map * '(1 2 3) '(10 20 30)) (10 40 90) (list (* 1 10) (* 2 20) (* 3 30)) map } (map h i h 1 i h 2 i h n i) map h i h i h i h i h i map h i h i h i h i > (map car '((1 2 3) (a b c) (x y z))) (1 a x) (list (car '(1 2 3)) (car '(a b c)) (car '(x y z))) > (map (lambda (a b c) (+ a b c)) '(1 2 3) '(10 20 30) '(100 200 300)) (111 222 333) > (let ((v 0))
101 ( 3) 233 (map (lambda (n) (set! v (+ v n))) '(1 2 3 4)) v) 10 1014 aplly (h i h i ) (define (calc op a b) (op a b)) h i op 2 3 4 (define (calc op2 a b) (op a b)) (define (calc op3 a b c) (op3 a b c)) (define (calc op4 a b c d) (op4 a b c d)) apply } (apply h i h i) h i h i h i h i h i h i apply } (apply h i h 1 i h i) (apply h i(append (list h 1 i ) h i)) ( )
234 10 Scheme ( ) > (apply cons (list 'kanga 'roo)) (kanga roo) > (apply number? (list 2001)) #t > (apply number? (list 2001 2010)) ERROR: apply: Wrong number of args > (apply + (list 1 2 3 4 5)) + 15 > (apply (lambda (f1 f2 x) (f1 (f2 x))) (list - sqrt 2)) -14142135623731 102 31 34 1021 A A (alist) car alist association list ( ) ((yama kawa) (tsu- ka-) (uteba hibiku)) A 3 yama, tsu-, uteba kawa, ka-, hibiku } (assq h i h i) h i h i h i #f h i eq? } (assv h i h i) assoq h i eqv?
102 235 } (assoc h i h i) assoq h i equal? > (define alist1 '((yama kawa) (tsu- ka-) (uteba hibiku))) #<unspecified> > (assq 'yama alist1) (yama kawa) > (assq 'uteba alist1) (uteba hibiku) > (assq 'jiji alist1) #f > (define alist2 '((1 one) (2 two))) #<unspecified> > (cadr (assv 1 alist2)) one > (cadr (assv 2 alist2)) two > (define alist3 '(((A) 1) ((B) 2) ((C) 3))) #<unspecified> > (assoc '(A) alist3) ((A) 1) > (assoc 'B alist3) #f A A cond case 1022 } (memq h i h i) h i h i #f
236 10 Scheme ( ) h i h i eq? } (memv h i h i) memq h i h i eqv? } (member h i h i) memq h i h i equal? > (define friends '(pooh piglet owl rabbit tiger)) #<unspecified> > (memq 'owl friends) (owl rabbit tiger) > (memq 'tiger friends) (tiger) > (memq 'alice friends) #f > (member (list 'pooh) '((pooh) (alice))) ((pooh) (alice)) > (member (list 'alice) '((pooh) (alice))) ((alice)) > (memv 11 '(1 2 3 5 7 11 13 17)) (11 13 17) > (memv 9 '(1 2 3 5 7 11 13 17)) #f 1023 cons cons alist ((p 314) (e 2718)) ( A h i h i 1021 )
102 237 alist2 alist () x 10 p 314 e 2718 101: A (x 10) (p 314) (e 21718)) alist2 alist () e-pair x 10 p 314 e 0 102: (set-cdr! e-pair 0) A > (define alist (list (cons 'p 314) (cons 'e 2718))) #<unspecified> > alist ((p 314) (e 2718)) A > (define alist2 (cons (cons 'x 10) alist)) #<unspecified> > alist2 ((x 10) (p 314) (e 2718)) > alist ((p 314) (e 2718)) > (assoc x alist2) (x 10) > (assoc x alist)
238 10 Scheme ( ) a () jugemu 103: (Jugemu) a jugemu 104: (e 2718) 101 e 0 e A A (e 0) A 101 (e 2718) cdr car cdr } (set-car! h i h i) h i car h i } (set-cdr! h i h i) h i cdr h i 101 e-pair A (e 2718) > (define e-pair (caddr alist2)) #<unspecified> > e-pair
102 239 (e 2718) (set-cdr! e-pair 0) 102 e 0 > (set-cdr e-pair 0) #<unspecified> > alist2 ((x 10) (p 314) (e 0)) > alist ((p 314) (e 0)) e-pair car > (set-car e-pair 'zero) #<unspecified> > alist2 ((x 10) (p 314) (zero 0)) > alist ((p 314) (zero 0)) set-car!, set-cdr! car cdr cons a (jugemu) > (define a (cons 'jugemu '())) #<unspecified> > a (jugemu) 103 a cdr a > (set-cdr! a a) #<unspecified> a 104 cdr > a jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu jugemu
240 10 Scheme ( ) 3 ( ) set-car!, set-cdr! 103 ' ' (quasiquotations) `h i( (quasiquote h i)) h i h i,,@ ( ),,@ ' ` (back quote),h i i( (unquote h i i)) `h i,h i i `h i i (, ` ),@h i i( (unquote-splicing h i i)) `h i,@h i i h i i ( ),@h i i (,@ ` ) > 'pooh pooh > `(pooh piglet rabbit) (pooh piglet rabbit) > (define x 'honey) #<unspecified> > (list 'pooh 'loves x) (pooh loves honey) 3 C-g C-c (Mule Scheme C-c 2 )
104 241 > `(pooh loves,x) (pooh loves honey) > (define y '(piglet rabbit owl)) #<unspecified> > `(,y are friends of pooh) ((piglet rabbit owl) are friends of pooh) > `(,@y are friends of pooh) (piglet rabbit owl are friends of pooh),,@ > (define z 2) #<unspecified> > `((1 2 3) (,(* 1 z),(* 2 z),(* 3 z))) ((1 2 3) (2 4 6)) > `#(1 2 3,(* 1 z),(* 2 z),(* 3 z)) #(1 2 3 2 4 6) ` ` 1, 1 0, > `(2001 `(2010 x)) (2001 (quasiquote (2010 x))) (2001 `(2010 x)) > `(2001 `(2010,x)) (2001 (quasiquote (2010 (unquote x)))) (2001 `(2010,x)) > `(2001 `(2010,,x)) (2001 (quasiquote (2010 (unquote honey)))) (2001 `(2010,honey)) x 0,x x honey 104 (continuation) Scheme
242 10 Scheme ( ) ((+ 1 (+ 2 3)) (+ 2 3) 3 X Y X Y call-with-current-continuation } (call-with-current-continuation h i) h i 1 h i h i C (C h i ) h i (C h i ) (call-with-current-continuation h i) h i (C h i ) h i (call-with-current-continuation h i) procedure? #t 1041 (define a 3) (define (f cont) (if (= a 0) (cont #f) (set! a (- a 1))) (display "a=") (display a) (newline) a) f a 0 a 0 1 a f f a
104 243 (call-with-current-continuation f) f a 3 a 1 a f a (call-with-current-continuation f) > (call-with-current-continuation f) a=2 display 2 (call-with-current-continuation f) > (call-with-current-continuation f) a=1 1 > (call-with-current-continuation f) a=0 0 a 0 f (cont #f) > (call-with-current-continuation f) #f (call-with-current-continuation f) a= (cont #f) (cont #f) f (define b 3) (define (g cont) (if (= b 0) (h cont) (set! b (- b 1))) (display "b=") (display b) (newline) b) (define (h cont) (cont #f))
244 10 Scheme ( ) > (call-with-current-continuation g) b=2 display 2 (call-with-current-continuation g) > (call-with-current-continuation g) b=1 1 > (call-with-current-continuation g) b=0 0 > (call-with-current-continuation g) #f (non-local exit) C setjmp, longjmp 1042 4 ( ) (define *cont-top* #f) (define *cont-proc* #f) (define (start p) (define (start2 c) (set! *cont-top* c) (p)) (call-with-current-continuation start2)) start 4 C setjmp, longjmp longjmp Scheme ( Scheme )
104 245 (define (break) (define (break2 c) (set! *cont-proc* c) (*cont-top* "BREAK")) (call-with-current-continuation break2)) (define (resume) (*cont-proc* #t)) ( ) start proc proc break proc start resume proc proc (define (winnie) (display "POOH") (newline) (break) (display "BEAR") (newline)) > (start winnie) POOH "BREAK" > winnie winnie > (list "Alice" "Hatter") 1 ("Alice" "Hatter") > (+ 2001 9) 2 2010 > (resume) BEAR #<unspecified> proc (define (one-day) (display "BREAKFAST") (newline)
246 10 Scheme ( ) (break) (display "LUNCH") (newline) (break) (display "TEA") (newline) (break) (display "DINNER") (newline)) > (start one-day) BREAKFAST "BREAK" > (resume) LUNCH "BREAK" > (resume) TEA "BREAK" > (resume) DINNER #<unspecified>
11 3 1 = 3:141592 1000 2 Scheme 247
pppppppp pp pppppppp pppppppp pppppppp pppppppp 248 11 3 111 1111 1111 d ( ) L L = d d L = d p pp ppppp ppppppppppppppppppppppppppppppppppppppppppppppppp p d p p p ppp pppppp p p p p p ppppppppppppppppppppp p p pppppppppppppppppppppppppppp tan x = a=b tan,1 a=b = x pppppppp p pppppppppppppppp pppppppp p pppppppp x pppppppppppppppp ppppppp pppppppp a 90 pppppppp ppppppppppppppp ppppppp b 111: 112: tan tan,1 tan,1 tan,1 1111 (tan,1 ) 360 2 1111 x = =4(= 45 ) a = b tan(=4) = a=b = 1 tan,1 (1) = =4 = 4 tan,1 (1) tan,1 Scheme atan > (* 4 (atan 1)) 31415926535898 3:141592653589793 14
111 249 1112 tan,1 ( ) =4 = 4 tan,1 ( 1 5 ), tan,1 ( 1 239 ) = 20 tan,1 ( 1 7 ), 8 tan,1 ( 3 79 ) =4 = 12 tan,1 ( 1 18 )+8tan,1 ( 1 57 ), 5 tan,1 ( 1 239 ) > (* 4 (- (* 4 (atan (/ 1 5))) (atan (/ 1 239)))) 31415926535898 > (+ (* 20 (atan (/ 1 7))) (* 8 (atan (/ 3 79)))) 31415926535898 > (* 4 (+ (* 12 (atan (/ 1 18))) (* 8 (atan (/ 1 57))) (- (* 5 (atan (/ 1 239)))))) 31415926535898 tan,1 Scheme atan 2 1 ( ) 1
250 11 3 tan,1 x = = 1 1+ 1+x 2 1 1+x 2 1X n i=1 1 + 2 3 x 2 Q i (2m) m=1 Q i (2m +1) ( x 2 m=1 1+x + 2 4 2 3 5 ( x 2 + 2 4 6 3 5 7 ( x 2 1+x 2 )3 + 1+x 2 )io 1+x 2 )2 tan,1 x = 1X i=1 (,1) i,1 2i, 1 x2i,1 = x, 1 3 x3 + 1 5 x5, 1 7 x7 + Scheme arctan ;;; ARCTAN - atan(x) (define (arctan x) ;; LOOP - ; k k e ; sum - k-1 ; Ak - k ; k - ; e - (define (loop sum Ak k e) (if (<= (/ Ak sum) e) (/ (* sum x) (+ 1 (* x x))) (loop (+ sum Ak) (* (/ (* 2 (+ k 1)) (+ (* 2 (+ k 1)) 1)) (* Ak (/ (* x x) (+ 1 (* x x))))) (+ k 1) e))) ;; ARCTAN (loop 1 (* (/ 2 3) (/ (* x x) (+ 1 (* x x)))) 1 1e-14)) k 1 (1)
111 251 loop P k k, 1 e= 1:010,14 = 0 14 z } { 0:000 01 P k +1 k k A k A k+1 = k A k > (atan 01) Scheme 99668652491162e-3 > (arctan 01) 99668652491162e-3 > (arctan 10) 14711276743023 > (atan 10) 14711276743037 14 2 > (- (* 16 (arctan (/ 1 5))) (* 4 (arctan (/ 1 239)))) 31415926535898 >(+ (* 20 (arctan (/ 1 7))) (* 8 (arctan (/ 3 79)))) 31415926535898 2(k+1) A 2(k+1)+1 k x2 1+x 2 ( ) x =1=y x2 = 1 1+x 2 y 2 +1 y =5; 239 y 2 +1 tan,1 1 16 5 tan,1 1 239 P tan,1 1 5 P tan,1 1 239 P p ;; ;; PI = 16 atan(1/5) - 4 atan(1/239) ;; NOTE: 26 = 5*5 + 1 ;; 956 = 4*239 ;; 57122 = 239*239 + 1 2 e e Scheme
252 11 3 (define (simple-pi) ;; (define *max-loops* 10) ;; 16 atan(1/5) (define (loop-16atan1_5 P Ak k) (if (> k *max-loops*) (loop-4atan1_239 ; 16atan(1/5) (- P (/ 956 57122)) ; -4atan(1/239) (* (/ 956 57122) (/ 2 3)(/ 1 57122)) 1) (loop-16atan1_5 (+ P Ak) (* Ak (/ (* 2 (+ k 1)) (+ (* 2 (+ k 1)) 1)) (/ 1 26)) (+ k 1)))) ;; - 4 atan(1/239) (define (loop-4atan1_239 P Ak k) (if (> k *max-loops*) P (loop-4atan1_239 (- P Ak) (* Ak (/ (* 2 (+ k 1)) (+ (* 2 (+ k 1)) 1)) (/ 1 57122)) (+ k 1)))) ;; PI (loop-16atan1_5 (/ (* 16 5) 26) (* 16 (/ 5 26) (/ 2 3) (/ 1 26)) 1)) > (simple-pi) 31415926523898 1113 Scheme d 0 :d 1 d 2 d 3 d 4 d n,1 ( d i 0 9 ) n i d i ( 1 )
111 253 (make-register h i) h i (obj ':=0!) 0:0 (obj ':=1!) 1:0 (obj '+! obj 2 ) obj 2 (obj '-! obj 2 ) obj 2 (obj '*i! i) i (obj '/i! i) i (obj 'SHOW) ;;; (make-register ) ;;; ;;; ;;; 00 ;;; ;;; : ;;; (OBJ ':=0!) - 00 ;;; (OBJ ':=1!) - 10
254 11 3 ;;; (OBJ '+! OBJ2) - obj2 ;;; (OBJ '-! OBJ2) - obj2 ;;; (OBJ '*i! i) - i ;;; (OBJ '/i! i) - i ;;; (OBJ 'SHOW) - ;;; (define (make-register digits) ;; ; (define *num* #f) ; (define *size* 0) ; *num* (define *decimal-point* 3) ; (define *base* 100) ; 1 0 99 (define *uwidth* 2) ; 1 10 ; (define *digits/block* 10) ; 1 (define *digits/line* 50) ; 1 h zero!i h one!i h add!i h sub!i h imult!i h idiv!i h showi 00 10 obj2 obj2 I I ;; DISPATCH --- (define (dispatch msg) (case (car msg) ((:=0!) (zero!)) ((:=1!) (one!)) ((+!) (add! (cadr msg))) ((-!) (sub! (cadr msg))) ((*i!) (imult! (cadr msg))) ((/i!) (idiv! (cadr msg))) ((SHOW) (show)) ((NUM) *num*) ; (else (error "Unknown Message" msg)))) ;; MAKE-REGISTER ; (set! *size* (+ (quotient (+ digits *uwidth* -1) *uwidth*) *decimal-point*)) (set! *num* (make-vector *size* 0)) ; 00 (zero!) ; dispatch) 1 2 *decimal-point*
111 255 *num* 0 1 2 3 4 5 6 *decimal-point* 00 00 00 12 34 56 00 q q q q 113: ( 0:123456 ) *num* 0 (*decimal-point*, 1) *decimal-point* 0:123456 1113 *num* *decimal-point* 12 (*decimal-point*+1) 34 (*decimal-point*+2) 56 make-register *size* *num* 0:0 2 D = d 0 :d 1 d 2 d 3 d 4 d n,1 E = e 0 :e 1 e 2 e 3 e 4 e n,1 F = D + E = f 0 :f 1 f 2 f n,1 p p p p p p p d n,3 p p p p p p p c n,4 c n,3 d n,2 d n,1 c n,2 + + + e n,3 e n,2 e n,1 f n,3 f n,2 f n,1 114: d n,1 + e n,1 10 f n,1 = d n,1 + e n,1 10 d n,1 + e n,1 1 f n,1 c n,2 ( c n,2 =0 ) f n,2 f n,2 c n,3 d n,2 + e n,2 + c n,2 1 10 1113
256 11 3 ;; OBJ := OBJ+OBJ2 --- OBJ2 (define (add! obj2) (let ((num2 (obj2 'num))) (define (add-loop j carry) (if (>= j 0) (let ((mm (+ carry (vector-ref *num* j) (vector-ref num2 j)))) (vector-set! *num* j (modulo mm *base*)) (add-loop (- j 1) (quotient mm *base*))))) ; (add-loop (- *size* 1) 0))) num ; OBJ := OBJ-OBJ2 --- OBJ2 (define (sub! obj2) (let ((num2 (obj2 'num))) (define (sub-loop j borrow) (if (>= j 0) (let ((mm (- (vector-ref *num* j) (vector-ref num2 j) borrow))) (if (>= mm 0) (begin (vector-set! *num* j mm) (sub-loop (- j 1) 0)) (begin (vector-set! *num* j (+ *base* mm)) (sub-loop (- j 1) 1)))))) ; (sub-loop (- *size* 1) 0))) D = d 0 :d 1 d 2 d n,1 I E = D I = e 0 :e 1 e 2 e n,1 d i I 1 x n,1 = d n,1 I e n,1 = x n,1 mod 10, c n,2 = x n,1 10 2 x n,2 = d n,2 I + c n,2 e n,2 = x n,2 mod 10, c n,3 = x n,2 10 3 x n,3 = d n,3 I + c n,3 e n,3 = x n,3 mod 10, c n,4 = x n,3 10 4 I
111 257 ;; OBJ := OBJ*I --- I (define (imult! i) (define (mult-loop j carry) (if (>= j 0) (let ((mm (+ carry (* i (vector-ref *num* j))))) (vector-set! *num* j (modulo mm *base*)) (mult-loop (- j 1) (quotient mm *base*))))) ; (mult-loop (- *size* 1) 0)) e 0 e 1 e 2 e 3 e 4 e 5 e 6 I d 0 d 1 d 2 d 3 d 4 d 5 e 0 I ppppp p p p p p p p p p p d 1 e 1 I p p p p p p p p p p 115: D = d 0 :d 1 d 2 d n,1 I E = D=I = e 0 :e 1 e 2 e n,1 3 1113 D 1 d 0 I e 0 ;; OBJ := OBJ/I --- I (define (idiv! i) (define (div-loop j m) (if (< j *size*) (let* ((mm (+ (* m *base*) (vector-ref *num* j)))) (vector-set! *num* j (quotient mm i)) (div-loop (+ j 1) (modulo mm i))))) ; (div-loop 0 0))
258 11 3 10 50 ;; (define (show) ; (define (show-integer-part) (loop 0 1 '() *decimal-point* "")) ; ( ) (define (show-decimal-part) (loop *decimal-point* 1 '() *size* " ")) ; (define (loop index digits strs max-index space-str) (define (mk-nstr n) (let* ((str (string-append (make-string *uwidth* #\0) (number->string n)))) (string->list (substring str (- (string-length str) *uwidth*) (string-length str))))) (if (null? strs) (if (< index max-index) (loop (+ index 1) digits (mk-nstr (vector-ref *num* index)) max-index space-str)) (begin (display (car strs)) (if (= (modulo digits *digits/block*) 0) (display space-str)) (if (= (modulo digits *digits/line*) 0) (newline)) (loop index (+ digits 1) (cdr strs) max-index space-str)))) ; SHOW (show-integer-part) (display "") (newline) (show-decimal-part) (newline)) > (define a (make-register 50)) 50 #<unspecified> > (a ':=1!) #<unspecified> > (a 'show) 000001 0000000000 0000000000 0000000000 0000000000 0000000000 #<unspecified> > (a '/i! 3) #<unspecified> > (a 'show)
111 259 000000 3333333333 3333333333 3333333333 3333333333 3333333333 #<unspecified> > (define b (make-register 50)) #<unspecified> > (b ':=1!) #<unspecified> > (b '/i! 9) b=011111 #<unspecified> > (b '+! b) 033333+011111 #<unspecified> > (b 'show) 000000 4444444444 4444444444 4444444444 4444444444 4444444444 #<unspecified> simple-pi 1000 1001 1000 1000 tan,1 D k A k A k < 10,D k K tan,1 K D P k A k = Q k m=1 (2m) Q k m=1 (2m +1) ( x 2 1+x 2 )k A k ( x2 1+x 2 ) k k K x 2 ( 1+x 2 )k < 10,D 10 k> D log 10 x 2 1+x 2
260 11 3 K = D log 10 x 2 1+x 2 3 x =1=y K = D log 10 1 y 2 +1 ( y 5 239 ) loops ;; (define (loops d y) (inexact->exact (+ (floor (/ d (log10 (+ (* y y) 1)))) 1))) ;; 10 (define (log10 x) (/ (log x) (log 10))) 1000 tan,1 1 5 tan,1 1 239 n 1 = 707 n 2 = 211 tan,1 1 5 707 3 3 4 4 4 register-size ;; (define (register-size D y) (+ D (inexact->exact (ceiling (+ (log10 (loops D y)) 1))))) pi simple-pi ;;; ;;; PI --- ;;; (define (pi D) ; MEMO: ; 26 = 5*5 + 1 ; 956 = 4*239 ; 57122 = 239*239 + 1 3 bxc x b4:8c =4,b9c =9 ( floor )
111 261 (let ((PI #f) ; (Ak #f) ; k (n1 #f) ; atan(1/5) (n2 #f) ; atan(1/239) (size #f)) ; h loopsi h register-sizei h log10i ;; PI:= 16atan(1/5) (define (loop-16atan1_5 k) (if (> k n1) (begin ; PI := (- PI (/ 956 57122)) (Ak ':=1!) ; 4atan(1/239) (Ak '*i! 956) ; Ak (Ak '/i! 57122) ; (PI '-! Ak) ; Ak (956/57122) ; Ak := (* (/ 956 57122) (/ 2 3)(/ 1 57122)) (Ak '*i! 2) (Ak '/i! 3) (Ak '/i! 57122) (loop-4atan1_239 1)) (begin ; PI := PI + Ak (PI '+! Ak) ; Ak := (* Ak (/ (* 2 (+ k 1)) (+ (* 2 (+ k 1)) 1)) ; (/ 1 26)) (Ak '*i! (* 2 (+ k 1))) (Ak '/i! (* (+ (* 2 (+ k 1)) 1))) (Ak '/i! 26) (loop-16atan1_5 (+ k 1))))) ;; PI := PI - 4atan(1/239) (define (loop-4atan1_239 k) (if (> k n2) 'done (begin ; PI := (- PI Ak) (PI '-! Ak) ; Ak := (* Ak (/ (* 2 (+ k 1)) (+ (* 2 (+ k 1)) 1)) ; (/ 1 57122)) (Ak '*i! (* 2 (+ k 1))) (Ak '/i! (+ (* 2 (+ k 1)) 1)) (Ak '/i! 57122) (loop-4atan1_239 (+ k 1))))) ;; PI ; (set! n1 (loops D 5)) (set! n2 (loops D 239)) (set! size (max (register-size D 5) (register-size D 239))) ; (set! PI (make-register size)) (set! Ak (make-register size))
262 11 3 ; ; PI := (/ (* 15 5) 26) (PI ':=1!) (PI '*i! (* 16 5)) (PI '/i! 26) ; Ak := (* 16 (/ 5 26) (/ 2 3) (/ 1 26)) (Ak ':=1!) (Ak '*i! (* 16 5 2)) (Ak '/i! (* 26 3 26)) (loop-16atan1_5 1) ; (PI 'show))) 1000 > (pi 1000) 000003 1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679 8214808651 3282306647 0938446095 5058223172 5359408128 4811174502 8410270193 8521105559 6446229489 5493038196 4428810975 6659334461 2847564823 3786783165 2712019091 4564856692 3460348610 4543266482 1339360726 0249141273 7245870066 0631558817 4881520920 9628292540 9171536436 7892590360 0113305305 4882046652 1384146951 9415116094 3305727036 5759591953 0921861173 8193261179 3105118548 0744623799 6274956735 1885752724 8912279381 8301194912 9833673362 4406566430 8602139494 6395224737 1907021798 6094370277 0539217176 2931767523 8467481846 7669405132 0005681271 4526356082 7785771342 7577896091 7363717872 1468440901 2249534301 4654958537 1050792279 6892589235 4201995611 2129021960 8640344181 5981362977 4771309960 5187072113 4999999837 2978049951 0597317328 1609631859 5024459455 3469083026 4252230825 3344685035 2619311881 7101000313 7838752886 5875332083 8142061717 7669147303 5982534904 2875546873 1159562863 8823537875 9375195778 1857780532 1712268066 1300192787 6611195909 2164201989 3517 #<unspecified> 3 1001 sin; cos
111 263 1 tan,1 2 tan,1 3 pi 4 5 6 7 8 ** Scheme (bignum) 1000 1000! = 1000 999 998 2 1 9 e =2:71828 f(x) =e x f(x) d f(x) = f(x) i dx (i 2 =,1) e i =,1 e e = 1X k=0 1 k! = 1+ 1 1 + 1 1 2 + 1 1 2 3 + (Scheme ) 10 * 1000
264 11 3 11 *** Scheme ( C Fortran, Pascal ) 12 (a) 4 A; B; T; X A = 1, B = 1= p 2, T = 1=4, X = 1 (b) A B : (x y x y ) i Y A ii A (A + B)=2 p iii B B Y iv T T, X (Y, A) 2 v X 2 X (c) (A+B)2 4T (, \ " ) 13 ***** ( ) Fortran C ( ), \, 1991 1," B-889,, \ ",, 1991 4
111 265,, \ I,", 1981 4,, \ II,", 1981 9,, \,", 1985 6
266 11 3 112 (1 + 2) Scheme Scheme ((6-3) + (3 + (2 + 2))) 1121 : (2 + 4) 3 (h 1 i h i h 2 i) h i 2 calc-exp0 calc-exp0 1 (calc-exp0 '(2 + 4)) 6 (calc-exp0 '2) 2 calc-exp0 exp (calc-exp0 '(2 + 4)) exp (2 + 4) exp (6 ) exp ((2 + 4) ) 1 exp n 1 2 exp op 3 exp n 2 4 A op + n 1 + n 2 calc-exp0 B op - n 1, n 2 calc-exp0
112 267 calc-exp0 (define (calc-exp0 exp) (cond ((number? exp) exp) ((list? exp) (case (length exp) ((3) (let* ((n1 (list-ref exp 0)) (op (list-ref exp 1)) (n2 (list-ref exp 2))) (if (and (number? n1) (number? n2) (or (eq? op '+) (eq? op '-))) (case op ((+) (+ n1 n2)) ((-) (- n1 n2))) (error "syntax error")))) (else (error "syntax error")))) (else (error "syntax error")))) calc-exp0 > (calc-exp0 '2) h i 2 > (calc-exp0 '(2 + 7)) 2+7=9 9 > (calc-exp0 '(32-6)) 32, 6=26 26 > (calc-exp0 'abc) ERROR: syntax error > (calc-exp0 '(2 + 7 + 5)) (h 1 i h ih 2 i) ERROR: syntax error
268 11 3 > (calc-exp0 '(+ 4 10)) ERROR: syntax error (h 1 ih ih 2 i) (calc-exp0 '(2+7)) (2 + + 7 ) > (calc-exp0 '(2+7)) ERROR: syntax error Scheme 2+7 calc-exp0 (grammer) ( ) ( ) (syntax) G0-1: h i := h ij ( h ih ih i ) G0-2: h i := + j - G0-3: h i := 0 j 1 j 2 j j -1 j -2 j 116: G0 116 G0 4 := 4 h i ( +10-10 +-10 ) Scheme Scheme Scheme "(5 + 8" )
112 269 j (( + ) BNF (Backus-Naur form) 116 G0 h i h i ( h ih ih i ) h i 20-189 h i + - G0 h i ) (h 1 i h ih 2 i) ( G0-1) ) ( 4 h ih i) h 1 i 4 ( G0-3) ) ( 4 + h i) h 1 i + ( G0-2) ) ( 4 + 10 ) h 2 i 10 ( G0-3) h i ) h i ( G0-1) ) 4 h i 4 ( G0-3) G0 hi (derivation) calc-exp0 (2 + 7 + 5) G0 G0 (4 + 10) 5 1 (4 + 10) 2 h i := ( h ih ih i ) ( G0-1) 3 + - (4 + 10) ( G0-3 G0-2) 5
270 11 3 (parsing) (semantics) (4 + 10) 4, +, 10 (4 + 10) 4+10 ( ) 14 6 S0-1: Eval(h i) = h i S0-2: Eval(( h 1 i + h 2 i )) = Eval(h 1 i) + Eval(h 2 i) S0-3: Eval(( h 1 i - h 2 i )) = Eval(h 1 i), Eval(h 2 i) 117: S0 G0 ( ) 117 Eval(x) x x (10 + 4) Eval((4 + 10)) = Eval(4) + Eval(10) ( S0-2) = 4 + Eval(10) ( S0-1) = 4+10 ( S0-1) = 14 (4 + 10) 14 6 (operational semantics), (denotational semantics) (axiomatic semantics)
112 271 1122 : ((6 + 3) - 5) G1 118 G0 ( h i h i h i ) G1 h i := ( h ih ih i ) G1-1: h i := h ij ( h ih ih i ) G1-2: h i := + j - G1-3: h i := 0 j 1 j 2 j j -1 j -2 j 118: G1 S1 119 S1-1: Eval(h i) = h i S1-2: Eval(( h 1 i + h 2 i )) = Eval(h 1 i) + Eval(h 2 i) S1-3: Eval(( h 1 i - h 2 i )) = Eval(h 1 i), Eval(h 2 i) 119: S1 G1 S1 ( ) calc-exp1 (define (calc-exp1 exp) (cond ((number? exp) exp) ((list? exp)
272 11 3 (case (length exp) ((3) (let* ((n1 (calc-exp1 (list-ref exp 0))) ;* (op (list-ref exp 1)) (n2 (calc-exp1 (list-ref exp 2)))) ;* (if (and (number? n1) (number? n2) (or (eq? op '+) (eq? op '-))) (case op ((+) (+ n1 n2)) ((-) (- n1 n2))) (error "syntax error")))) (else (error "syntax error")))) (else (error "syntax error")))) calc-exp0 ;* calc-exp0 (n1 (list-ref exp 0)) calc-exp1 (n1 (calc-exp1 (list-ref exp 0))) calc-exp0 calc-exp1 > (calc-exp1 '(2 + 2)) 4 > (calc-exp1 '((2 + 3) + 4)) 9 > (calc-exp1 '((2 + 3) + (1 + 2))) 8 > (calc-exp1 '((2 + 3) + (1 + (1 + 1)))) 8 > (calc-exp1 '((2 + 3) + ((2 + 2) + ((3 + 3) + 1)))) 16 ((2 + 3) + 4) ((2 + 3) + 4) = (2 + 3) + 4 (2 + 3) = 2 + 3 + 4 2 = 2 + 3 + 4
112 273 = 2+ 3 + 4 3 = 2 +3 + 4 = 2+3 + 4 2+3 = 5+ 4 4 = 5+4 5+4 = 9 1123 : calc-exp2 AC 0 (Min h i ) h i (Min h i ) h i MR (calc-exp2 'AC) (calc-exp2 '(Min (3 + 4)) (calc-exp2 '(MR + 6)) 3+4=7 6 (calc-exp2 '(Min (MR + 4)) 4 G2 S2 1110 1111 Min MR AC (Min 0)
274 11 3 G2-1: h i := h ij ( h ih ih i ) j AC j MR j (Min h i ) G2-2: h i := + j - G2-3: h i := 0 j 1 j 2 j j -1 j -2 j 1110: G2 S2-1: Eval(h i) = h i S2-2: Eval(AC) =0 ( 0 ) S2-3: Eval(MR) = S2-4: Eval(( h 1 i + h 2 i )) = Eval(h 1 i) + Eval(h 2 i) S2-5: Eval(( h 1 i - h 2 i )) = Eval(h 1 i), Eval(h 2 i) S2-4: Eval((Min h i )) = Eval(h i) (Eval(h i) ) 1111: S2 Scheme *memory* calc-exp0 calc-exp1 : (define (calc-exp1 exp) (cond ((number? exp) exp) ((list? exp) ))) h i AC MR AC 0 MR ( calc-exp3 ) ;*
112 275 (define *mameory* 0) ;* (define (calc-exp3 exp) (cond ((eq? exp 'AC) ;* AC (set! *memory* 0) ;* 0) ;* 0 ((eq? exp 'MR) ;* MR *memory*) ;* ((number? exp) exp) ((list? exp) ))) (Min h i ) (Min h i ) calc-exp3 h i *memory* (Min h i ) h i calc-exp2 calc-exp1 ;* (define *memory* 0) ;* (define (calc-exp2 exp) (cond ((eq? exp 'AC) ;* (set! *memory* 0) ;* *memory*) ;* ((eq? exp 'MR) ;* *memory*) ;* ((number? exp) exp) ((list? exp) (case (length exp) ((2) ;* (cond ;* ((eq? (car exp) 'Min) ;*(Min h i) (set! *memory* (calc-exp2 (cadr exp))) ;* *memory*) ;* (else (error "illegal expression")))) ;* ((3) (let* ((n1 (calc-exp2 (list-ref exp 0))) (op (list-ref exp 1)) (n2 (calc-exp2 (list-ref exp 2)))) (if (and (number? n1) (number? n2) (or (eq? op '+) (eq? op '-))) (case op
276 11 3 ((+) (+ n1 n2)) ((-) (- n1 n2))) (error "syntax error")))) (else (error "syntax error")))) (else (error "syntax error")))) > (calc-exp2 'AC) 0 > (calc-exp2 'MR) 0 > (calc-exp2 '(Min (3 + 4))) 3+4 7 > (calc-exp2 'MR) 7 > (calc-exp2 '(Min (MR + (10-5)))) (10, 5) 12 > (calc-exp2 'MR) 12 1124 ( ) Scheme eq?, car, cdr Scheme C, Fortran, Pascal 1 calc-exp2 * 2 calc-exp2 / 3 * 2 G2 S2
112 277 4 314 calc-exp2 pi 314 > (calc-exp2 'pi) 314 > (calc-exp2 '(10 * pi)) 314 > (calc-exp2 '(2 * pi)) 628 calc-exp2 5 sin x (sin h i) calc-exp2 > (calc-exp2 '(sin 0)) 00 > (calc-exp2 '(sin (pi / 6))) 499770102643102e-3 6 ***** ( ) > (calc-str-exp "2") 2 > (calc-str-exp "(2 + 7)") 9 > (calc-str-exp "((3 + 2) - 4)") 1 calc-str-exp C Pascal, Fortan calc-exp-str calc-exp2
278 11 3, \ ", 4,, 1994 M Hennessy (, ), \," Information&Computing-76,, 1993 J E Hopcroft, J D Ullman (,,, ), \ I," Information&Computing-3,, 1984
12 Scheme Scheme Scheme Scheme Scheme Scheme Scheme Scheme Scheme ( ) Scheme Scheme Scheme Scheme TS (Tiny Scheme Scheme) TS (SANS SERIF) TS Scheme (typewriter) 121 1211 TS Scheme 279
280 12 Scheme (QUOTE h i) (IF h ih 1 ih 2 i) (IF h ih 1 i) (BEGIN h 1 ih 2 i ) (DEFINE h ih i) (DEFINE h i (LAMBDA )) (DEFINE (h ih i) h i ) (SET! h ih i) (LAMBDA h ih 1 ih 2 i ) NULL?, EQ?, CONS, CAR, CDR, PAIR?, +, {, =, >, QUIT QUIT TS TS Scheme Scheme LIST? LENGTH TS #F (DEFINE LIST? (LAMBDA (S) (IF (NULL? S) #T (IF (PAIR? S) (LIST? (CDR S)) #F)))) (DEFINE LENGTH (LAMBDA (S) (DEFINE LENGTH-LOOP (LAMBDA (REST LEN) (IF (NULL? REST)
121 281 LEN (LENGTH-LOOP (CDR REST) (+ LEN 1))))) (IF (LIST? S) (LENGTH-LOOP S 0) #F))) 1212 Scheme ( 121 ) REP 121: 1 - - (Read) (Evaluate) (Print) Read-Evaluate-Print REP 2
282 12 Scheme 3 4 cons, car, + (primitive procedure) 122 1221 REP ts ts ( ) REP ;;; ts --- (define (ts) (newline) (display "TS (TINY SCHEME IN SCHEME)") (newline) (ts:reset-environ) ; (ts:intern-primitive-procedures) ; (ts:read-eval-print-loop) ; REP #t) REP 121 REP TS TS ts:read-eval-print-loop ts:read-eval-print TS QUIT #f REP REP ; ( ) (define *ts:top-level-continuation* #f) ;;; REP (define (ts:read-eval-print-loop)
122 283 (letrec ((loop ; REP (lambda () ; ts:read-eval-print (if (call-with-current-continuation ts:read-eval-print) (loop) ; REP (begin ; #f (display "GOOD BYE") (newline)))))) (loop))) ; REP ts:read-eval-print REP *ts:top-level-continuation* 1 ts:prompt 2 ts:read-user-input 3 ts:eval 4 ts:print-value ts:top-environ force-output *ts:scheme-system-has-force-output* #f (force-output 139 ) (define (ts:read-eval-print cont) (set! *ts:top-level-continuation* cont) (ts:prompt) ; (let ((user-input (ts:read-user-input))) ; (let ((val (ts:eval user-input (ts:top-environ)))) ; (ts:print-value val) ; #t))) (define *ts:scheme-system-has-force-output* #t) ; (define (ts:prompt) (display "] ") (if *ts:scheme-system-has-force-output*
284 12 Scheme (force-output)) #t) ts:error TS ts:error (lambda msg ) (define ts:error (lambda msg (letrec ((loop (lambda (s) (if (null? s) (begin (newline) (newline) (*ts:top-level-continuation* #t)) ; (begin (display (car s)) (display " ") (loop (cdr s))))))) (newline) (display "TS ERROR") (newline) (loop msg)))) 1222 TS Scheme Scheme Scheme (TS) Scheme Scheme Scheme (TS) TS 2 TS Scheme TS 51 (cons h i hscheme i) TS car TS 2001 Scheme (TS-TAG:INTEGER 2001) TS #T (TS-TAG:BOOLEAN #t)
122 285 *ts:null-obj* TS ts:null? TS (define *ts:null-obj* (cons 'TS-TAG:NULL '())) (define (ts:null? ts-obj) (eq? ts-obj *ts:null-obj*)) *ts:true* *ts:false* TS ts:make-boolean Scheme / TS / (define *ts:true* (cons 'TS-TAG:BOOLEAN #t)) (define *ts:false* (cons 'TS-TAG:BOOLEAN #f)) (define (ts:make-boolean scheme-obj) (if scheme-obj *ts:true* *ts:false*)) ts:boolean? TS (define (ts:boolean? ts-obj) (eq? (car ts-obj) 'TS-TAG:BOOLEAN)) ts:make-integer Scheme TS ts:integer? TS (define (ts:make-integer n) (cons 'TS-TAG:INTEGER n)) (define (ts:integer? ts-obj) (eq? (car ts-obj) 'TS-TAG:INTEGER)) ts:make-symbol Scheme TS ts:symbol? TS (define (ts:make-symbol scheme-obj) (cons 'TS-TAG:SYMBOL scheme-obj)) (define (ts:symbol? ts-obj) (eq? (car ts-obj) 'TS-TAG:SYMBOL)) TS TS TS Scheme TS cdr ts:get-scheme-value TS Scheme
286 12 Scheme (define (ts:get-scheme-value ts-obj) (cdr ts-obj)) ts:cons 2 ts:pair? TS ts:car ts:cdr ts:cons car cdr (ts:car (ts:cons s1 s2)) = s1 (ts:cdr (ts:cons s1 s2)) = s2 (define (ts:cons s1 s2) (cons 'TS-TAG:PAIR (cons s1 s2))) (define (ts:pair? ts-obj) (eq? (car ts-obj) 'TS-TAG:PAIR)) (define (ts:car s) (cadr s)) (define (ts:cdr s) (cddr s)) ts:car ts:cdr (define (ts:cadr s) (ts:car (ts:cdr s))) (define (ts:cddr s) (ts:cdr (ts:cdr s))) (define (ts:caddr s) (ts:car (ts:cddr s))) (define (ts:cadddr s) (ts:cadr (ts:cddr s))) ts:make-compound-procedure (LAMBDA (X1 X2 ) EXP1 EXP2 ) ts:make-compound-procedure ts-parameter-list, body, env 3 ts-parameter-list (X1 X2 ) body (EXP1 EXP2 ) env (91 ) ( )
122 287 (define (ts:make-compound-procedure ts-parameter-list body env) (letrec ((param-rev-loop (lambda (ts-params rev-params nargs) (if (ts:null? ts-params) (list 'TS-TAG:COMP-PROC rev-params nargs body env) (param-rev-loop (ts:cdr ts-params) (cons (ts:car ts-params) rev-params) (+ nargs 1)))))) (param-rev-loop ts-parameter-list '() 0))) (define (ts:compound-procedure? ts-obj) (eq? (car ts-obj) 'TS-TAG:COMP-PROC)) (define (ts:get-arglist-compound-procedure proc) (list-ref proc 1)) (define (ts:get-nargs-compound-procedure proc) (list-ref proc 2)) (define (ts:get-body-compound-procedure proc) (list-ref proc 3)) (define (ts:get-env-compound-procedure proc) (list-ref proc 4)) ts:make-primitive-procedure TS TS Scheme TS (define (ts:make-primitive-procedure proc name nargs) (list 'TS-TAG:PRIM-PROC proc name nargs))
288 12 Scheme (define (ts:primitive-procedure? ts-obj) (eq? (car ts-obj) 'TS-TAG:PRIM-PROC)) Scheme TS (define (ts:get-body-primitive-procedure proc) (define (ts:get-name-primitive-procedure proc) (define (ts:get-nargs-primitive-procedure proc) (cadr proc)) (caddr proc)) (cadddr proc)) Scheme TS ts:scheme-obj->ts-obj Scheme TS Scheme TS car cdr TS (define (ts:scheme-obj->ts-obj scheme-obj) (cond ((null? scheme-obj) *ts:null-obj*) ((boolean? scheme-obj) (ts:make-boolean scheme-obj)) ((integer? scheme-obj) (ts:make-integer scheme-obj)) ((symbol? scheme-obj) (ts:make-symbol scheme-obj)) ((pair? scheme-obj) (ts:cons (ts:scheme-obj->ts-obj (car scheme-obj)) (ts:scheme-obj->ts-obj (cdr scheme-obj)))) (else (ts:error "ILLEGAL INPUT:" scheme-obj)))) 1223 ts:read-user-input 121 read TS Scheme TS (define (ts:read-user-input) (let ((scheme-obj (read))) ; Scheme (if (eof-object? scheme-obj) ; #f (ts ) (*ts:top-level-continuation* #f) ; (ts:scheme-obj->ts-obj scheme-obj))))
122 289 121 ts:print-exp ts:print-exp TS Scheme car cdr (define (ts:print-value ts-exp) (ts:print-exp ts-exp) (newline)) (define (ts:print-exp ts-exp) (cond ((or (ts:boolean? ts-exp) (ts:integer? ts-exp) (ts:symbol? ts-exp) (ts:null? ts-exp)) (display (ts:get-scheme-value ts-exp))) ((ts:primitive-procedure? ts-exp) (display "<primitive-procedure:") (display (ts:get-name-primitive-procedure ts-exp)) (display ">")) ((ts:compound-procedure? ts-exp) (display "<compound-procedure>")) ((ts:pair? ts-exp) (display "(") (ts:print-exp (ts:car ts-exp)) (display " ") ; (ts:print-exp (ts:cdr ts-exp)) (display ")")))) 1224 ( 1) 121 112 ts:eval 2 exp env exp env
290 12 Scheme ts:lookup-binding env ts:special-form? ts:do-special-form ts:do-application (define (ts:eval exp env) (cond ((ts:null? exp) ;** exp) ; ((ts:boolean? exp) ;** exp) ; ((ts:integer? exp) ;** exp) ; ((ts:symbol? exp) ;** (ts:lookup-binding ; exp env)) ((ts:pair? exp) ;** ( ) (if (ts:special-form? exp) (ts:do-special-form exp env) ; (ts:do-application exp env))) ; (else ; (ts:error "ILLEGAL OBJECT:" exp)))) 1225 ( ) TS 121 A X, Y 1, 2 ( (X 1) (Y 2) ) car cdr (binding) (frame) Scheme (DEFINE X 1) (DEFINE Y 2) (DEFINE F
122 291 () new-env env () () () () X 1 Y 2 Y 1 X 1 Y 2 122: 123: F (LAMBDA (Y) (+ Y 2000))) 3 X, Y, F (F ) ((X 1) (Y 2) (F h i) ) (F 1) F 1 Y F Y 1 F (Y 1) F Y 1 (Y ) (environment) 122 ( ) F F ( hf i h i) hf i ((Y 1)) 122 123 F Y 10 2001 (+ Y 2000) 123 new-env
292 12 Scheme 2001 env 2002 ts:eval (ts:reset-environ) (ts:top-environ) (ts:lookup-binding var env) env var (ts:define-var var val env) env var val (ts:set-var! var val env) env var val (ts:extend-environ vars vals env) vars vals i env 1226 ( 2 ) ts:special-form? car (define (ts:special-form? exp) (case (ts:get-scheme-value (ts:car exp)) ((QUOTE IF BEGIN DEFINE SET! LAMBDA) #t) (else #f)))
122 293 ts:do-special-form (QUOTE h i) h i h i (IF h ih 1 ih 2 i) h i h 1 i IF h 2 i IF (BEGIN h 1 ih 2 i ) h 1 i, h 2 i BEGIN ts:eval-begin (DEFINE h ih i) h i h i DEFINE (SET! h ih i) h i h i h i h i DEFINE (LAMBDA h ih 1 ih 2 i ) ts:make-compound-procedure (define (ts:do-special-form exp env) (case (ts:get-scheme-value (ts:car exp)) ((QUOTE) ;** (QUOTE OBJ) (ts:cadr exp)) ((IF) ;** (IF CON EXP1 EXP2) (let ((con (ts:eval (ts:cadr exp) env))) (if (not (eq? con *ts:false*)) (ts:eval (ts:caddr exp) env) (ts:eval (ts:cadddr exp) env)))) ((BEGIN) ;**(BEGIN EXP1 )
294 12 Scheme (ts:eval-begin (ts:cdr exp) env)) ((DEFINE) ;**(DEFINE VAR EXP) (ts:define-var (ts:cadr exp) (ts:eval (ts:caddr exp) env) env) (ts:cadr exp)) ((SET!) ;**(SET! VAR EXP) (let ((val (ts:eval (ts:caddr exp) env))) (ts:set-var! (ts:cadr exp) val env) val)) ((LAMBDA) ;**(LAMBDA (VAR) EXP1) (ts:make-compound-procedure (ts:cadr exp) (ts:cddr exp) env)) (else ; (ts:error "ILLEGAL SPECIAL FORM:" exp)))) (BEGIN hexp 1 i) ts:eval-begin exps hexp 1 i ts:eval ts:eval ( ts:do-application-compount-procedure ) (define (ts:eval-begin exps env) (letrec ((begin-loop (lambda (rest last) (if (ts:null? (ts:cdr rest)) (ts:eval (ts:car rest) env) (begin-loop (ts:cdr rest) (ts:eval (ts:car rest) env)))))) (if (ts:null? exps) *ts:null-obj* (begin-loop exps *ts:null-obj*)))) 1227 2 (LAMBDA )
122 295 ts:do-application ts:eval-args (define (ts:do-application exp env) (let ((proc (ts:eval (ts:car exp) env)) ; (args (ts:eval-args (ts:cdr exp) env))) ; (cond ((ts:compound-procedure? proc) ;** (ts:do-application-compound exp env proc args)) ((ts:primitive-procedure? proc) ;** (ts:do-application-primitive exp env proc args))))) ts:eval-args (FOO EXP1 EXP2 EXP3) ts:eval-args args (EXP1 EXP2 EXP3) args Scheme args (hexp3 i hexp2 i hexp1 i) (define (ts:eval-args args env) (letrec ((ev-arg-loop (lambda (args results) (if (ts:null? args) results ; (ev-arg-loop (ts:cdr args) (cons (ts:eval (ts:car args) env) results)))))) (ev-arg-loop args '()))) 1228 ts:do-application-primitive apply Scheme TS (define (ts:do-application-primitive exp env proc args)
296 12 Scheme (let ((proc-nargs (ts:get-nargs-primitive-procedure proc))) (if (or (eq? 'any proc-nargs) ; (= (length args) proc-nargs)) (apply ; ; (ts:get-body-primitive-procedure proc) (reverse args)) (ts:error "ILLEGAL NUMBER OF ARGS TO" (ts:get-name-primitive-procedure proc))))) 1229 : 91 (186 ) DEFINE (DEFINE (PROC ARG) ) (DEFINE PROC (LAMBDA (ARG) )) (DEFINE MAKE-WALLET (LAMBDA (MONEY) (LAMBDA (AMOUNT) (IF (> AMOUNT MONEY) "NOT ENOUGH MONEY" (BEGIN (SET! MONEY ({ MONEY AMOUNT)) MONEY))))) (MAKE-WALLET 100) (LAMBDA (AMOUNT) (IF )) (DEFINE W1 (MAKE-WALLET 100)) W 124 ( ) W1 (W1 10) W1 ( (IF (>AMOUNT MONEY) ))
122 297 : : : AMOUNT (IF ) MONEY : 100 () W1 : W2 : h i MAKE-WALLET : 124: (DEFINE W1 (MAKE-WALLET 100)) ts:do-application-compound (define (ts:do-application-compound exp env proc args) (if (= (length args) ; (ts:get-nargs-compound-procedure proc)) (let ((new-env ; (ts:extend-environ ; (ts:get-arglist-compound-procedure proc) args (ts:get-env-compound-procedure proc)))) (ts:eval-begin ; (ts:get-body-compound-procedure proc) new-env)) (ts:error "ILLEGAL NUMBER OF ARGS TO" (ts:get-name-primitive-procedure proc)))) ts:extend-environ (ts:extend-environ vars vals env) vars vals ( ) vars (VAR1 VAR2 ) vals (VAL1 VAL2 ) ((VAR1 VAL1) (VAR2 VAL2) ) env
298 12 Scheme : : : AMOUNT (IF ) MONEY : 100 : : : AMOUNT (IF ) () W1 : W2 : h i MAKE-WALLET : MONEY : 200 125: (DEFINE W2 (MAKE-WALLET 200)) (define (ts:extend-environ vars vals env) (letrec ((loop (lambda (vars vals bindings) (if (null? vars) ; (cons bindings env) ; ENV (loop (cdr vars) ; (cdr vals) (cons (cons (car vars) (car vals)) bindings)))))) (loop vars vals '()))) MAKE-WALLET 2 (DEFINE W1 (MAKE-WALLET 100)) (DEFINE W2 (MAKE- WALLET 200)) 125 W1, W2 SET! MOMEY ( ) (F2 1) (DEFINE A 2001)
122 299 () A : F1 : F2 : 2001 h i : (A) : (F1 A) : : (N) : (+ N A) : 126: F1 F2 (DEFINE F1 (DEFINE F2 (LAMBDA (N) (+ N A))) (LAMBDA (A) (F1 A))) F1, F2 126 ( ) F2 1 A 1 F2 ( 127 ) F2 (F1 A) A 1 F1 F1 1 N 1 F1 ( F1 ) F1 F1 A A 2001 128 12210 ( ) ts:reset-environ 129
300 12 Scheme F2 () A : 1 A : F1 : F2 : 2001 h i : (A) : (F1 A) : : (N) : (+ N A) : 127: F2 F2 () A : 1 F1 A : F1 : F2 : 2001 h i N : 1 : (A) : (F1 A) : : (N) : (+ N A) : 128: F1 env () () 129:
122 301 env env () () () () X 1 Y 2 Z 3 X 1 Y 2 1210: 1211: *ts:bindings* ts:top-environ (define *ts:bindings* (define (ts:reset-environ) (define (ts:top-environ) #f) (set! *ts:bindings* (list '()))) *ts:bindings*) (ts:find-binding var env) env var (h i #f h i) (ts:find-binding2 var env) env var (h i #f h i) 2 ts:lookup-binding ts:find-binding ts:error (define (ts:lookup-binding var env) (let ((binding (ts:find-binding var env))) (if binding (cdr binding)
302 12 Scheme (ts:error "UNBOUND VARIABLE:" (ts:get-scheme-value var))))) ts:define-var (ts:define-var var val env) ts:define-var env var val 1210 1211 env var val (define (ts:define-var var val env) (let* ((binding (ts:find-binding2 var env))) (if binding (set-cdr! binding val) (set-car! env (cons (cons var val) (car env))))) val) ts:set-var! (ts:set-var! var val env) ts:find-binding var ts:error ( SET! ) (define (ts:set-var! var val env) (let* ((binding (ts:find-binding var env))) (if binding (set-cdr! binding val) (ts:error "UNBOUND VARIABLE:" (ts:get-scheme-value var))))) var ts:find-binding ts:find-binding2 ts:find-binding ( car cdr ) #f (define (ts:find-binding var env) (letrec ((loop (lambda (env)
122 303 (if (null? env) #f ; #f (let ((binding (assoc var (car env)))) (if binding binding ; (loop (cdr env)))))))); (loop env))) ts:find-binding2 (env ) ts:find-bindings (define (ts:find-binding2 var env) (assoc var (car env))) 12211 121 ts:intern-prim-proc name Scheme proc Scheme TS proc any (define (ts:intern-prim-proc name proc nargs) (ts:define-var (ts:scheme-obj->ts-obj name) (ts:make-primitive-procedure proc name nargs) (ts:top-environ))) (ts:intern-primitive-procedures (define (ts:intern-primitive-procedures) (ts:intern-prim-proc 'NULL? tsp:null? 1) (ts:intern-prim-proc 'EQ? tsp:eq? 2) (ts:intern-prim-proc 'CONS tsp:cons 2) (ts:intern-prim-proc 'CAR tsp:car 1) (ts:intern-prim-proc 'CDR tsp:cdr 1) (ts:intern-prim-proc 'PAIR? tsp:pair? 1)
304 12 Scheme (ts:intern-prim-proc '+ tsp:+ 'any) (ts:intern-prim-proc '- tsp:- 2) (ts:intern-prim-proc '= tsp:= 2) (ts:intern-prim-proc '> tsp:> 2) (ts:intern-prim-proc 'QUIT tsp:quit 0)) Scheme TS (define (tsp:cons s1 s2) (ts:cons s1 s2)) (define (tsp:car s) (ts:car s)) (define (tsp:cdr s) (ts:cdr s)) (define (tsp:null? s) (ts:make-boolean (ts:null? s))) (define (tsp:eq? s1 s2) (ts:make-boolean (eq? (ts:get-scheme-value s1) (ts:get-scheme-value s2)))) (define (tsp:pair? s) (ts:make-boolean (ts:pair? s))) (define tsp:+ (lambda args ; args (letrec ((loop (lambda (nums sum) ; nums sum (if (null? nums) (ts:make-integer sum) (loop (cdr nums) (+ (ts:get-scheme-value (car nums)) sum)))))) (loop args 0)))) (define (tsp:- n1 n2) (ts:make-integer (- (ts:get-scheme-value n1) (ts:get-scheme-value n2)))) (define (tsp:= n1 n2)
123 305 (ts:make-boolean (= (ts:get-scheme-value n1) (ts:get-scheme-value n2)))) (define (tsp:> n1 n2) (ts:make-boolean (> (ts:get-scheme-value n1) (ts:get-scheme-value n2)))) TS + ( { 2 ) + Scheme tsp:+ QUIT #f #f TS (define (tsp:quit env) (*ts:top-level-continuation* #f)) 123 Scheme (ts) Scheme TS Scheme TS TS Scheme > (ts) TS (TINY SCHEME IN SCHEME) ] ] TS 1 n SUM ] (DEFINE SUM (LAMBDA (N) (IF (= N 0) 0 (+ N (SUM (- N 1)))))) SUM SUM N
306 12 Scheme ] (DEFINE N (QUOTE POOH)) N SUM (SUM 100) 1 100 SUM N ] (SUM 100) 5050 ] N POOH ] (DEFINE MAKE-WALLET (LAMBDA (INITIAL-MONEY) (DEFINE MONEY INITIAL-MONEY) (DEFINE EXTRACT (LAMBDA (AMOUNT) (SET! MONEY (- MONEY AMOUNT)) MONEY)) EXTRACT)) MAKE-WALLET ] (DEFINE W1 (MAKE-WALLET 100)) W1 ] (DEFINE W2 (MAKE-WALLET 200)) W2 ] (W1 10) 90 ] (W2 10) 190 124 TS Scheme
124 307 0 1 2 p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p car cdr 1212: Scheme 1241 cons ( 1212 ) > (define foo (cons 'pooh 'bear)) #<unspecified> > (set! foo (cons 'piglet 'pig)) #<unspecified> foo (pooh bear) cons x (piglet pig) Scheme (garbage collection) 1 ( ) 1
308 12 Scheme foo pooh bear (a) (define foo (cons 'pooh 'bear)) foo pooh bear piglet pig (b) foo 1213: 1 car cdr 2 Scheme Garbage collecting 1242 TS Scheme
124 309 1 12 1 1 * 2 2 / 2 ( ) 3 { 4 { 1 5 { { * * 6 DISPLAY NEWLINE 7 ABS 8 QUOTIENT MODULO 9 LIST? 10 LENGTH 11 LIST-TAIL 12 REVERSE 1 Scheme
310 12 Scheme 13 APPEND 14 LIST-REF 15 SET-CAR! SET-CDR! 16 BOOLEAN? 17 NOT 18 19 20 4=2 4=3 21 22 IF (IF h ih i) 23 AND 24 OR 25 COND 26 CASE 27 (DEFINE (h i h i) h i) (DEFINE h i (LAMBDA (h i) h i)) 28 SUM (DEFINE SUM (LAMBDA (N) (IF (= N 0) 0 (+ N (SUM (- N 1))))))
124 311 (SUM 2) N 1 0 29 LET LET (LET ((h 1 ih 1 i) (h 2 ih 2 i) ) h i ) ((LAMBDA (h 1 ih 2 i ) h i ) h 1 ih 2 i ) 30 LET* LET* (LET* ((h 1 i h 1 i) (h 2 i h 2 i) ) h i ) ((LAMBDA (h 1 i) ((LAMBDA (h 2 i) h i ) h 2 i) h 1 i) 31 LOAD 32 TS
312 12 Scheme 33 **** Scheme C Pascal Fortran 34 *****
Appendix A ASCII ASCII 1 c c E 64 + 5 = 69 +0 +1 +2 +3 +4 +5 +6 +7 0 nul soh stx etx eot enq ack bel 8 bs ht nl vt np cr so si 16 dle dc1 dc2 dc3 dc4 nak syn etb 24 can em sub esc fs gs rs us 32! " # $ % & ' 40 ( ) * +, - / 48 0 1 2 3 4 5 6 7 56 8 9 : ; < = >? 64 @ A B C D E F G 72 H I J K L M N O 80 P Q R S T U V W 88 X Y Z [ \ ] ^ _ 96 ` a b c d e f g 104 h i j k l m n o 112 p q r s t u v w 120 x y z { } ~ del A1: ASCII 32 ( ) 0 31 127 (control character) (control character) 1 ASCII American Standard Code for Information Interchange ` ' ASCII EBCDIC IBM 313
314 Appendix A ASCII ( Scheme ) 0 (null) 8 (backspace) 9 (tab) 10 (newline) 12 (page) 13 (return) 32 (space) #\h i #\hsohi #\hpagei 1, 12
Appendix B Scheme } hvariablei hvariablei } hconstanti ( ) } 'hdatumi (quote hdatumi) } (quote hdatumi) hdatumi } (hopi harg 1 i ) harg 1 i hopi } (lambda hformalsi hbodyi) hformali hbodyi } (define hvari hexpi) 4 (define (hvari hformalsi) hbodyi) (define hvari (lambda (hformalsi) hbodyi)) 4 (define (hvari hformali) hbodyi) (define hvari (lambda hformali hbodyi)) } (if htesti hconsequenti halternatei) 4 (if htesti hconsequenti) Copyright c Hirotsugu Kakugawa, 1997 Permission is granted to make and distribute copies of this reference manual provided the copyright notice and this permission notice are preserved on all copies ( : ) 315
316 Appendix B Scheme } (cond hclause 1 i hclause 2 i ) } (case hkeyi hclause 1 i ) } (and htest 1 i ) #f } (or htest 1 i ) #f } (set! hvari hexpri) } (let hbindingsi hbodyi) hbodyi 4 (let* hbindingsi hbodyi) hbodyi ( ) } (letrec hbindingsi hbodyi) hbodyi ( ) } (begin hexpr 1 i hexpr 2 i ) 4 (do ((hvar 1 i hinit 1 i hstep 1 i) ) (htesti hexp 1 i ) hbodyi) htesti hbodyi 4 (let hvari hbindingsi hbodyi) let 4 (delay hexpri) 4 (force promise) } (quasiquote obj ) quote unquote } `obj (quasiquote obj ) } (unquote obj ) (quasiquote ) obj },obj (unquote obj ) } (unquote-splicing obj ) (quasiquote ) obj },@obj (unquote-splicing obj )
317 } (not obj ) obj } (boolean? obj ) obj? } (eqv? obj 1 obj 2 ) obj 1 obj 2? } (eq? obj 1 obj 2 ) obj 1 obj 2? } (equal? obj 1 obj 2 ) obj 1 obj 2? } (pair? obj )? } (cons obj 1 obj 2 ) } (car pair ) car } (cdr pair ) cdr } (set-car! pair obj ) car } (set-cdr! pair obj ) cdr } (caar pair ) (car (car pair )) } (cadr pair ) (car (cdr pair )) } (cdddar pair ) (cdr (cdr (cdr (car pair )))) } (cddddr pair ) (cdr (cdr (cdr (cdr pair )))) } (null? obj )? } (list? obj )? } (list obj ) obj } (length list) list } (append list ) } (reverse list)
318 Appendix B Scheme 4 (list-tail list k) list } (list-ref list k) list k } (member obj list) list obj? ( equal? ) } (memq obj list) list obj? ( eq? ) } (memv obj list) list obj? ( eqv? ) } (assoc obj alist) ( equal? ) } (assq obj alist) ( eq? ) } (assv obj alist) ( eqv? ) } (symbol? obj )? } (symbol->string sym) } (string->symbol str ) } (number? obj )? } (complex? obj )? } (real? obj )? } (rational? obj )? } (integer? obj )? } (exact? z) ( )? } (inexact? z)? } (= z 1 z 2 z 3 ) z 1 = z 2 = :::? } (< x 1 x 2 x 3 ) z 1 <z 2 < :::? } (> x 1 x 2 x 3 ) z 1 >z 2 > :::? } (<= x 1 x 2 x 3 ) z 1 z 2 :::?
} (>= x 1 x 2 x 3 ) z 1 z 2 :::? } (zero? z)? } (positive? x)? } (negative? x)? } (odd? n)? } (even? n)? } (max x 1 x 2 ) } (min x 1 x 2 ) } (+ z 1 ) } (* z 1 ) } (- z 1 z 2 ) 4 (- z 1 z 2 ) } (- z) } (/ z 1 z 2 ) 4 (/ z 1 z 2 ) } (/ z) } (abs x) } (quotient n 1 n 2 ) } (remainder n 1 n 2 ) } (modulo n 1 n 2 ) n 2 n 1 } (gcd n 1 ) } (lcm n 1 ) 4 (numerator q) 4 (denominator q) 319
320 Appendix B Scheme } (floor x) x ( ) } (ceiling x) x ( ) } (truncate x) x x } (round x) x 4 (rationalize x y) x y 4 (exp z) exp z 4 (log z) log z ( e) 4 (sin z) sin z 4 (cos z) cos z 4 (tan z) tan z 4 (asin z) asin z 4 (acos z) acos z 4 (atan z) atan z 4 (atan y x) atan (y=x) 4 (sqrt z) p z 4 (expt y z) y z 4 (make-rectangular x y) x + yi 4 (make-polar r t) re it 4 (real-part z) z 4 (imag-part z) z 4 (magnitude z) z 4 (angle z) z 4 (exact->inexact z) 4 (inexact->exact z)
321 } (number->string n) } (number->string n radix) ( radix ) } (string->number str) } (string->number str radix) ( radix ) } (char? obj )? } (char=? ch 1 ch 2 )? } (char<? ch 1 ch 2 ) ch 1 < ch 2? } (char>? ch 1 ch 2 ) ch 1 > ch 2? } (char<=? ch 1 ch 2 ) ch 1 ch 2? } (char>=? ch 1 ch 2 ) ch 1 ch 2? } (char-ci=? ch 1 ch 2 ) ( / ) ch 1 = ch 2? } (char-ci<? ch 1 ch 2 ) ( / ) ch 1 < ch 2? } (char-ci>? ch 1 ch 2 ) ( / ) ch 1 > ch 2? } (char-ci<=? ch 1 ch 2 ) ( / ) ch 1 ch 2? } (char-ci>=? ch 1 ch 2 ) ( / ) ch 1 ch 2? } (char-alphabetic? ch)? } (char-numeric? ch)? } (char-whitespace? ch)? } (char-upper-case? letter )? } (char-lower-case? letter )? } (char->integer ch) } (integer->char n) } (char-upcase ch)
322 Appendix B Scheme } (char-downcase ch) } (string? obj )? } (make-string k) k } (make-string k ch) k ch } (string ch ) ch } (string-length str ) } (string-ref str k) k } (string-set! str k ch) k } (string=? str 1 str 2 ) str 1 =str 2? } (string<? str 1 str 2 ) str 1 <str 2? } (string>? str 1 str 2 ) str 1 >str 2? } (string<=? str 1 str 2 ) str 1 str 2? } (string>=? str 1 str 2 ) str 1 str 2? } (string-ci=? str 1 str 2 ) ( / ) str 1 =str 2? } (string-ci<? str 1 str 2 ) ( / ) str 1 <str 2? } (string-ci>? str 1 str 2 ) ( / ) str 1 >str 2? } (string-ci<=? str 1 str 2 ) ( / ) str 1 str 2? } (string-ci>=? str 1 str 2 ) ( / ) str 1 str 2? } (substring str start end ) } (string-append str ) } (string->list str ) } (list->string ch ) 4 (string-copy str ) str
323 4 (string-fill! str ch) str ch } (vector? obj )? } (make-vector k) k 4 (make-vector k fill) k ( fill ) } (vector obj ) ( ) } (vector-length vect) } (vector-ref vect k) } (vector-set! vect k obj) k obj } (vector->list vect) } (list->vector list) 4 (vector-fill! vect e) } (procedure? obj )? } (apply proc list) list proc 4 (apply proc arg 1 list) (apply proc (append (list arg 1 ) list)) } (map proc list 1 list 2 ) list j proc } (for-each proc list 1 list 2 ) list j proc 4 (force promise) promise } (call-with-current-continuation proc) proc } (call-with-input-file str proc) str proc } (call-with-output-file str proc) str proc } (input-port? obj )?
324 Appendix B Scheme } (output-port? obj )? } (current-input-port) } (current-output-port) } (with-input-from-file str thunk ) str proc } (with-output-to-file str thunk ) str proc } (open-input-file lename) } (open-output-file lename) } (close-input-port port ) } (close-output-port port ) } (read [port ]) ( port ) } (read-char [port ]) ( port ) 1 } (peek-char [port ]) ( port ) 1 } (eof-object? obj )? 4 (char-ready? [port ]) ( port )? } (write obj [port ]) ( port ) obj } (display obj [port ]) ( port ) obj } (newline [port ]) ( port ) } (write-char char [port ]) ( port ) char } (load lename) Scheme 4 (transcript-on lename) 4 (transcript-off) (SCM ) p (quit [n]) ngscm (n )
325 p (error obj1 obj 2 ) read-eval-print p errobj p (abort) read-eval-print p (defined? sym) sym? p (gc) p (terms) GNU General Public Licese p (list-file str ) p (system str ) p (getenv str ) p most-positive-fixnum p most-negative-fixnum p internal-time-units-per-second 1 p (get-internal-run-time) p (get-internal-real-time) p (get-decode-time) 9 0 8 8 p (get-universal-time) 1970 1 1 0 0 0 GMT p (decode-universal-time time) (get-universal-time) get-decode-time p (read-line [port ]) ( port ) 1 p (read-line! str [port ]) ( port ) 1 str p (write-line str [port ]) ( port ) str 1 p (file-exists? lename) lename? p (delete-file lename) lename
326 Appendix B Scheme p (rename-file lename1 lename 2 ) lename 1 lename 2 p (stat port ) (stat lename) port lename 0 11 : (st dev) inode (st ino) ( ) (st mode) (st nlink) (st uid) (st gid) (st rdev) (st size) (st atime) (st mtime) (st ctime) ( C stat ) p (file-position? port ) port p (file-set-position port n) port n p (force-output [port ]) ( port ) p (isatty? port ) port? p (chdir str ) str
Appendix C NGSCM ngscm ngscm lename ngscm -s lename ngscm -a lename ngscm Scheme NGSCM NGSCM NGSCM ( ) C-x C-c C-z, C-g C-l M-x redraw-display (apropos) (tutorial) C-h a C-h b C-h c C-h C-h C-h t NGSCM GNU Emacs Version 18 NGSCM Copyright c Free Software Foundation, Inc Permission is granted to make and distribute copies of this card provided the copyright notice and this permission notice are preserved on all copies (, ( )) 327
328 Appendix C NGSCM, C-u, 4 C-u, 4 M-0, M-1,, M-9 C-u M- - NGSCM Dired C-x C-f C-x C-s C-x s C-x i C-x C-w C-x d C-s C-r C-M-s M-x search-again M-s M-r, : c DEL ESC C-g C-s C-r C-q c, C-s C-r C-g,, c c C-q, c C-q c : C-b C-f M-b M-f
329 C-p C-n ( ) C-a C-e M-[ M-] C-x [ C-x ] ( ) M-< M-< : C-v M-v (, ) DEL C-d M-DEL M-d ( ) M-0 C-k C-k C-w C-y C-@ C-SPC C-x C-x :, SPC, DEL,! ESC M-% M-x query-replace-regexp C-x 1 C-x 0 2 C-x 2 C-M-v C-x o M-x shrink-window C-x ^ C-x 4 f C-o
330 Appendix C NGSCM C-x C-o 1 M-SPC M-q C-x f C-x / M-u M-l M-c C-x C-u C-x C-l C-x b C-x C-b C-x k C-x 4 b M-~ C-x ( C-x ) C-x e C-u C-x ( ( ) : TAB 1 SPC, RET C-g Scheme / Scheme Interaction Scheme Scheme M-x scheme-mode M-x run-scheme (Scheme Interaction ) 1 M-p 1 M-n 1 C-p 1 C-n, M-ESC
331 (Scheme Interaction ) 1 1 S Defuns defun defun defun, C-j C-c C-e C-c C-r C-M-f C-M-b C-M-k C-M-a C-M-e C-M-h TAB LFD C-j dired dired dired : C-x d C-d d c e f SPC n p r u DEL x, : 1 (dot) 0 * 1 + 0 1? [ ] [^ ] ^ $ c \c (\or") \ \( \) n \n \`
332 Appendix C NGSCM \' \b \B \< \> \w \W C-t M-! C-x =, M-x make-backup-les emacs M-x emacs-version ng M-x ng-version
Appendix D Scheme Scheme Scheme 1 D1 Scheme 1996 1 Scheme ( ) Scheme Scheme compcompliers WWW URL http://wwwidiomcom/free-compilers/ FTP : ftp://ftpidiomcom/pub/compilers-list/free-compilers FTP File Transfer Protocol 2 ELK (Extension Language Kit) : 22 : Scheme X-Window Unix : Oliver Laumann : Unix, Ultris, MS-DOS 1 ( ) 2 FTP ftp 333
334 Appendix D Scheme : FTP ( ) ftp://fptxorgcontrib/elk-22targz MIT Scheme : 72 : Scheme Emacs Scheme : Scheme : 68000 CPU (HP9000, Sun3, NeXT), MIPS CPU (Decstation, Sony, SGI), i386 CPU (MS-DOS, Windows, Unix) : FTP ( ) ftp://altdorfaimitedu/archive/scheme-72 NGSCM : 331 : Scheme SCM 4e1 Ng 13L Scheme : (SCM Aubrey Jeer Ng ) : Unix (SunOS 41x, Solaris 24, FreeBSD 2x), MS-DOS ( MS-DOS NGSCM 2 ) : FTP ( ) ftp://gullsehiroshima-uacjp/pub/ngscm/ PC-Scheme : 303 : Emacs : Texas Instruments : i286, i386 CPU IBM PC MS-DOS : $95 rww@ibukicom SCM : 4e1 : Scheme : Aubrey Jeer : Amiga, Atari-ST, Macintosh, MS-DOS, OS/2, NOS/VE, Unicos, VMS, Unix : FTP ( ) ftp://nexusyorkuca/pub/oz/scheme/new/* SOID (Scheme In One Defun) : 30 : Scheme : George Carrette : Unix, VMS, Amiga, Macintosh, Windows NT, OS/2 : FTP ( ) ftp://ftpcsindianaedu/pub/gjc/ VSCM
D2 FTP 335 : V0r3 : Scheme C : Matthis Blume : Unix, Macintosh : FTP ( ) ftp://ftpcsindianaedu/pub/scheme-repository/imp/vscm*targz D2 FTP Unix FTP FTP FTP FTP Scheme MS-DOS NGSCM Unix FTP gullsehiroshima-uacjp 1 FTP FTP % ftp gullsehiroshima-uacjp RET Connected to gullsehiroshima-uacjp 220 gull FTP server (Version wu-24(10) Sun Apr 24 11:22:55 JST 1994) ready 2 ftp Name (gullsehiroshima-uacjp:kakugawa): ftp RET 331 Guest login ok, send your complete e-mail address as password 3 ( ) Password: h i RET FTP ( FTP ) 230-WELCOME TO OUR FTP SERVER!! 230-230-This ftp server provides the following software: 230 Guest login ok, access restrictions apply Remote system type is UNIX Using binary mode to transfer files ftp> FTP
336 4 ftp> type binary RET 200 Type set to I 5 NGSCM ftp> cd pub/ngscm RET 250 CWD command successful 6 ftp> dir RET 200 PORTcommand successful 150 Opening ASCII mode data connection for/bin/ls total 3074 drwxr-xr-x 21226 1000 512 May 7 1994 MS-DOS-222 -rw-r--r-- 11226 1000 769 Nov 1606:19 PATCH-326-327 -rw-r--r-- 11226 1000 404661 Dec 27 1993 ngscm-112targz -rw-r--r-- 11226 1000 506958 Jul 29 1994 ngscm-2231targz -rw-r--r-- 11226 1000 601809 May 7 1994 ngscm-223targz -rw-r--r-- 11226 1000 521253 Nov 1303:37 ngscm326-ng13l+scm4e1targz -rw-r--r-- 11226 1000 521665 Nov 1606:26 ngscm327-ng13l+scm4e1targz -rw-r--r-- 11226 1000 521971 Jan 1102:19 ngscm331-ng13l+scm4e1targz 226 Transfer complete 7 FTP ftp> get ngscm331-ng13l+scm4e1targz RET local: ngscm331-ng13l+scm4e1targz remote: ngscm331-ng13l+scm4 e1targz 200 PORT command successful 150 Opening BINARY mode data connection for ngscm331-ng13l+scm4e1 targz (521971 bytes) 226 Transfer complete 521971 bytes received in 67 seconds (76 Kbytes/s) 8 FTP ftp> quit RET 9 Scheme Steven Allen Robenalt, \Catalog of Free Compilers and Interpreters," http://wwwidiomcom/free-compilers/, 1995/05/04
::::::::::::::::::::::::::47 :::::::::::::::::::::::::::: 47 ::::::::::::::::::47,248 inode ::::::::::::::::::::::::::::::326 IBM 7090 ::::::::::::::::::::::::::::::::32 :::::::::::::::::::::::::::: 18 ::::::::::::::::::::::::::::::::104 ASCII :::::::::::::::::::4,118,313 ::::::::::::::::::::::::::::::7 ( ) ::::::::::::::::::130 :::::::::::::::::::::::::::::::32 ::::::112 ::::::::::::7 ::::::::::::112 :::::::::::::::::::::::::::::::::::::42 ASCII :::::::::::::::::::::::::118 :::::::::::::::::::::::::::205 ::::::::::::::::::31,120 Emacs :::::::::::::::::::::::::157 ( ) :::::::::::::::::::::::168 ( ) ::::::::::::::::::::::::79 ( ) ::::::::::326 ( ) ::::::::::::::326 :::::::::::::::::::::::::::::71,184 ::::::::::::::::::::::::::::::::::::270 ::::::::::::::::::::::::::::::::::270 :::::::::::::::::::::::::3 :::::::::::::::::::166 ( ) ::::::::::165 ( ) ::::::::::165 :::::::::::::::::::::333,335 :::::::::::::::::::::::112 :::::::::::::::::::::::: 12,266 :::::::::::::::::::::::::30,90,99,240 :::::::::::::::::::::::::::240 ::::::::::::::::::::::::74,80,170 2 :::::::::::::::::::::170 :::::::::::::::::::::::170 :::::::::::::::::::::::171 :::::::::::::::::171 :::::::::::::::::171 ::::::::::::::: 14 ::::::::::::::::::::::::::::::::312 :::::::::::::::::::::::::::::::::::::15 A ::::::::::::::::::::::::::::::::234 Ada :::::::::::::::::::::::::::::::::::::10 A ::::::::::::::::::::::::::::::::290 :::::::::::::::::::::::::::::::74 :::::::::::::::::::::157,158 ::::::::::::::::::::::12,73,157,173 Ng ::::::::::::::::::::::::::::157 NGSCM :::::::::::::::::::::::::::::::::17 NGSCM ::::::::::::::::::::::::::19 NGSCM ::::::::::::::::::::::::::76 NGSCM ::::::::::::::::::::::::::19 EBCDIC ::::::::::::::::::118,313 :::::::::::::::::::::::::::::::::::91 else ::::::::::::::::::::::::::::::::::143 ::::::::::::::::::::::::::::::::::::::248 ::::::::::::::::::::::::::::::::::::248 ::::::::::::::::::::::::::::::248,262 ::::::::::::::::::::::::::::105,134 :::::::::::::::::::::::::::250 :::::::::::::::::::::::::249 :::::::::::::::::::::::::::7 ( ) ::::::::::::::171 ( ) :::::::::::::::::::: 326 ::::::::::::::::::::::::::::::::::120 :::::::::::::::::::::::::::16,246 :::::::::::::::::::::::186,286 :::::::::::::::::8 ( ) ::::::::::::::::::::::::::32 ::::::::::::::::::::::::::17,74,158 ::::::::::::::::::::::79,158 car ::::::::::::::::::::::::::::::::34,238 ( ) :::::::::::::::::::::::159 :::::::::::::::::::::::::::::80,120,149 337
338 ::::::::::::::::::::::::133,199,314 :::::::::::::::::::::::::::::::::::::12 ::::::::::::::::::::::::::::::::148,263 ::::::::::::::::::::::::::::::::::::120 ::::::::::::::::::::::::::::::::314 ::::::::::::::::::::::::::35 ( ) ::::::::::::::::::125 ( ) :::::::::::::::::::: 131 ( ) ::::::::::::::::::163 ::::::::::::::::::31 :::::::::::::::::::::::::::::::::::78 ( ) ::::::::::::::::::130 ::::::::::::::::::::::::::::::::::128 :::::::::::::::::::::::::::::::::::40,125 :::::::::::::::::::162 :::::::::::::::::::::::::::::::::::10 :::::::::::::::::::::::54,286,291,297 ::::::::::::::::::::::::::::::::::::246 :::::::::::::::::::326 ::::::::::::::::::::::::::::142,289,291 ::::::::::::::::::::::::::::: 291 ::::::::::::::::::::::::::::::::325 ( ) :::::::::::::::::::::8 :::::::::::::::::::::::::::249 ::::::::::::::264 :::::::::::::::307,325 ::::::::::::::::::::::::::::::::::::135 ::::::::::::::::::::::::::::::::138 ::::::::::::::::::::::::::::::::3 ::::::::::::::::::::::::::::::3,307 :::::::::::::::::::::::::::::::4,51 ( ) :::::::::::::::::::: 130 ::::::::::::::::::::::::::::::::::::5 ::::::::::::::::::::::::::::::::5 ::::::::::::::::::::::::::::::29,31,131 ::::::::::::::::::::::::::::::::211 (NGSCM ) ::::::::::::::::::::::::19 ::::::::::::::::::::79 :::::::::::::::::::53,280,282,287 :::::::::::::::::::::::::::::::76 ::::::::::::::::::::::::::::::::::9 ::::::::::::::::::::::::::::::::::::249 ::::::::::::::::::57,58,187,286,293 ::::::::::::::::::::::::::::::::127 ( ) :::::::::::::::::::::::127 ::::::::::::::::::::::::::::::::263 :::::::::::::::::::::::::::::::47 :::::::::::::::::::::::::::47,248 ::::::::::::165 ::::::::::::::::::::::::::::: 166 :::::::::::::::::::::::::::::::47 ::::::::::::::::::::::::: 206,204 ::::::::::::::::::::::::118,120,314 ::::::::::::::::::::::::::::::::::314 :::::::::::::::::::::::::::::::::47 :::::::::::::::::::::::::::::::::32 cdr :::::::::::::::::::::::::::::::34,238 :::::::::::::::::::::65,145,146,230 ::::::::::::::::::::::::::::105,134 ( ) ::::::::::::326 :::::::::::::::::::::::::250 ::::::::::::::::::::::::::::::::241,308 :::::::::::::::::::::::::::314 ::::::::::::::::::::::::::::::::::::::5 :::::::::::::::::::::::::9,11,266 :::::::::::::::::::::134,135 :::::::::::::::::::::::::135 :::::::::::::::::::::::::::::::45,128 :::::::::::::::::::::::::::::::45,128 :::::::::::::::::::::::::::: 15 :::::::::::::::::::::::::::::::::10 ( ) :::::::::::::::::: 2 ::::::::::::::::::::::::::::::::252 ::::::::::::::::::::::::::::::::270 ::::::::::::::::::::::::::::::::::268 :::::::::::::::::::::::::::270 :::::::::::::::::::::::::::::::::46 ( ) ::::::::::::::::::::::::::79 ::::::::::::::::::::::::105,136,149 ::::::::::::::::::::::::::::::::::120 ::::::::::::::::79,157,158 cond- ::::::::::::::::::::::::::::::::::62 :::::::::::::::::::::::::::::::12 :::::::::::::::::::::::::::::::12 :::::::::::::::::::::::::::1 :::::::::::::::::::::2 ::::::::::::::::::::::::::::::::::::::::4 ( ) :::::::::::::::::::::::::::244 :::::::::::::::::::::::::::::::65,66,67 :::::::::::::::::::::::::::: 98 :::::::::::::::::::::::::::::::42 :::::::::::::::::::::::::::::::42 ::::::::::::::::::::::::::::::::::244 ::::::::::::::::::::::::::::::::::::186
339 :::::::::::::::::::::::::::::::::::46 ::::::::::::::::::::::::::::::::::::160 ( ) :::::::::::::::::::::::169 :::::::::::::::::::::::::::160 ::::::::::::::::::::::::::::::::::::205 CRT ::::::::::::::::::::::::3 C ::::::::::::::::::::::::::::::::::::::::10 :::::::::::::::::::::::::::::::::::76 ::::::::::::::::::::::::::::::::::17,21,26 :::::::::::::::::::::::::::281 ::::::::::::::::::::::::::::::46,47 ::::::::::::::::::::::::::::::::::128 :::::::::::::::::::::::325 :::::::::::::::::::::7,8 :::::::::::::::::::::::::::263 ::::::::::::::::::::::::::::::::::::::1 ::::::::::::::::::::::::::::::::3 (NGSCM ) ::::::::::::::::::::::::19 ::::::::::::::::::::::::::::::::3 ::::::::::::::::::::::::::::::::::::134 ::::::::::::::::::::::::::::: 134 :::::::::::::::::::::::::::::::::::::::42 ::::::::::::::::::::::::::::::::::::160 ::::::::::::::::::::::::::::::::314 ( ) :::::::::::::::::::: 326 ::::::::::::::::::::::::::::::::3 ::::::::::::::::::::::::::::38,47 (dene) ::::::::::::::::::::::::::150 :::::::::::::::::::::::13,148,149,179 ( ) ::::::::::::::325 :::::::::::::::::::::::::::::::::40,125 ( ) :::::::::::::::::::::::127 :::::::::::::::::::::::::::54,286,291 :::::::::::::::::::::::::::::::::::::43 ::::::::::::::::::::::::::::::::::240 ::::::::::::165 ::::::::::::::::::::::::::::: 166 :::::::::::::::::::::::::::::::::94 ::::::::::::::::::71,184 ::::::::::::::::::::::::::::::::::::120 Scheme ::::::::::::::::::::::::::::::::::10 Scheme Interaction ::::::::::177,178 Scheme :::::::::::::::::::::::17,333 Scheme ::::::::::::::::::::20 Scheme :::::::::::::::::::76,177,178 :::::::::::::::::::::::::::::::::68 stat :::::::::::::::::::::::::::::326 ::::::::::::::::::::::::::::::::120 :::::::::::::::::::::::::::314 :::::::::::::::::::::::::::::::::::73 ( ) :::::::::::::::::::: 163 :::::::::::::::::::::::86,115,227,278 ::::::::::::::::::::::::::::::::143 ::::::::::::::::::::::::::::118,313 :::::::::::::::::::::::::::::::::46 :::::::::::::::::::::::::::::::::40,125 :::::::::::::::::::::::::::::46,248 ::::::::::::::::::::::::::::141,298 :::::::::::::::::::::::::::293 ::::::::::::::::::::::::::::::::::::204 (cond ) ::::::::::::::::::::::::::::: 62 ( ) :::::::::::::::::::: 171 ( ) :::::::::::::::::::::::168 ::::::::::::::::::::::::::::::::::205 :::::::::::::::::::::::::::::67,147 :::::::::::::::::::::::::::270 ( ) :::::::::::::::::::::::163 ::::::::::::::::::::::::::::::::::::124 ::::::::::::::::::::::::::::::::141,290 :::::::::::::::::::::::::::::::::46 ::::::::::::::::::::::::::::: 166 :::::::::::::::::::::::8 ::::::::::::::::::::::::::::::::::::120 ::::::::::::::::::::::::157,164,179 ::::::::::::::::::::::::::::::::314 ::::::::::::::::::::::::::::::::::::165 ( ) :::::::::::::::::::::::::::166 ( ) :::::::::::::::::::::::::::166 :::::::::::::::::::::::: 46,248 ::::::::::::::::::::::::::::: 205 :::::::::::::::::::::::::3 ( ) ::::::::::::::::::::::77 :::::::::::::::::::::::::::::::::50 :::::::::::::::::::::::::::::::::::::28 :::::::::::::::::::::::::::335 :::::::::::::::::::::::::::::::24,155 ::::::::::::::::::::::::::::::::165,166 :::::::::::::::::::::::::::::::::12 ::::::::::::::::::::::::::::::3 ::::::::::::::::::::::::::::::::::::105 :::::::::::::::::::::::::::: 94 ( ) :::::::::::::::::::::::::::244 ::::::::::::::::::::::::::::::::248 ::::::::::::::::::::::::::::::::::::248
340 ::::::::::::::::::::::::::::::::32,33,238 ::::::::::::::::::::::::35 ( ) :::::::::::::::::::::::::130 ::::::::::::::::::::::::::::::::::::242 ( ) :::::::::::::::::::::::::263 ( ) ::::::::::::::::::::::::::54 :::::::::::::::::::::::::::::::::::::27 ::::::::::::::::::::::::::::::::125,131 :::::::::::::::::::::::::::::::::73 :::::::::::::::::::::::::::::::::::15 ::::::::::::::::::::::::::::53,55,139 :::::::::::::::::::::::::::: 54 ::::::::::::::::::::::::::55 :::::::::::::::::::::::::::::::94 ::::::::::::::::::::::::::::::::::3 ::::::::::::::::::::::::::32 ::::::::::::::::::::::::::::::::266,273 :::::::::::::::::::::::::::::::50 ::::::::::::::::::::::::::::::::207 :::::::::::::::::::::::::::::::::28 :::::::::::::::::::::::::::::::::22 :::::::::::::::::::::::140,179 :::::::::::::::::::::::139 ::::::::::::::::::::::::::::::::::::::248 :::::::::::::::::::::::::::::::::::::51 ::::::::::::::::::::::::::::::::155 ::::::::::::::::::::::::::::::::::::269 ::::::::::::::::::::::::::::::::141 :::::::::::::::::::::::::::141 :::::::::::::::::::::::::::::::34 ::::::::::::::::::::::::::::::::139 ::::::::::::::::::::::::::::::::::::4 :::::::::::::::::::::::::::47,132 :::::::::::::::::::::175 :::::::::::::::::::::::333 ::::::::::::::::::::::::::::::132,133 ::::::::::::::::::::::::::::::::3 (Scheme ) :::::::::::: 333 ::::::::::::::::::::::::::::::::136,158 ::::::::::::::::::::::::::::::::164 ::::::::::::::::::::::::::::: 134 :::::::::::::::::::::::::333 :::::::::::::::::::::::::::2 ::::::::::::::::::::::::::::::::::205 ::::::::::::::::::::::::::::::::::::122 ::::::::::::::::::::::::::::::::::::::9 ::::::::::::::::::::::::::::::::160,163 ::::::::::::::::::::::::::::::::::::3 ::::::::::::::::::::::::::::::::143 ::::::::::::::::::::::::::::::::::::153 ::::::::::::::::::::269 :::::::::::::::::::::::::240 :::::::::::::::::::::314 ::::::::::::::::::::::::47 :::::::::::::::::::::::::::::73,168 :::::::::::::::::::::::::168 :::::::::::::::::::::::::169 :::::::::::::::::::::::::168 :::::::::::::::::::::169 :::::::::::::::::::::::::139 ::::::::::::::::::::::::::::204,205 :::::::::::::::::9 Pascal :::::::::::::::::::::::::::::::::::10 :::::::::::::::::::::::::::::::18 :::::::::::::::::::::::::::335 :::::::::::::::::::::::::::: 26 :::::::::::::::::::::::::::::::::::::50 ( ) ::::::::::::::::::::::::56 :::::::::::::::::::::::::::::::26,27,54 :::::::::::::::::::::::::::::::::56 :::::::::::::::::::::::::244 :::::::::::::::::::::::::::::45,128 ::::::::::::::::::::::::::::::::::::::235 :::::::::::::::::::::::::::::::::27,281 ::::::::::::::::::::::::::::::::::282 ::::::::::::::::::::::::::::::::121,281 :::::::::::::::::::::::::::270 :::::::::::::::::::::::::::::::::22 BNF :::::::::::::::::::::::::::::: 269 ::::::::::::::::::::::::::::::::3,307 :::::::::::::::::::::::::::138 ::::::::::::::::::::::12,73,133,163 :::::::::::::::::::::137,222 :::::::::::::::::::::::326 :::::::::::::::::::::::::137 :::::::::::::::::::::163 :::::::::::::::::::::::326 :::::::::::::::::::::::163 :::::::::::::::::::::::::163 :::::::::::::::::::::163 :::::::::::::::::::135,326 :::::::::::::::::::::::12,133,195
341 :::::::::::::::::::::::163 :::::::::::::::::::::::::326 fundermental :::::::::::::::::76,177 :::::::::::::::::::::::149 :::::::::::::::::::::86,115,227,278 Fortran ::::::::::::::::::::::::::::::::::10 :::::::::::::::::::::::53,280,286 :::::::::::::::::::::::::::::::64,231 :::::::::::::::::::::::::::::::40,125 :::::::::::::::::::::::::::::::::::24 ::::::::::::::::::::::::::::::::::::120 ::::::::::::::::::::::::::::::::314 :::::::::::::::::::::::::::::::45 :::::::::::::::::::::::::128 ( ) :::::::::::::::::::::::130 :::::::::::::::::::::333 :::::::::::::::::::::::2 :::::::::::::::::::::::::::::::::38 ::::::::::::::::::::::::::::::::207 ( ) :::::::::::::::::::: 170 ::::::::::::::::::::::::::::::::207 ::::::::::::::::::::::::::::: 207 ::::::::::::::::::::::::::::::::::::125 ::::::::::::::::::::::::::::::::::::268 :::::::::::::141,286,296,298 ::::::::::::::::::::::::::::::::::3 :::::::::::::::::::::::::::1 :::::::::::::::::1,5,9,10 :::::::::::::::::::::::::::::1,21 :::::::::::::::::::::::6 ::::::::::::::::::::::::::14 ::::::::::::::::::::::::::::18,76 ::::::::::::::::::::::::::::::::246 :::::::::::::::::::::::::::::::::::47 ( ) ::::::::::::::::::169 :::::::::::::::::::::::::::::79,157 :::::::::::::::::::::::: 79,157 :::::::::::::::::::::::::::: 73 :::::::::::::::::::::::::::::::::::::27 :::::::::::::::::::::::::281 ::::::::::::::::::::::::::::::::122 ::::::::::::::::::::::::::::::::9 pair? list? ::::::::::::::::::35 ::::::::::::::::::::::::::::::::::::164 ::::::::::::::::::::::::::::::::169 ::::::::::::::::::::::::::::::::::::::9 ::::::::::::::::::::::::::::::::::312 :::::::::::::::::::::::::::::::::::5,12 ::::::::::::::::::::::::::::::::::273 ::::::::::::::::::::::::::::::134,135 ::::::::::::::::::::::::::::::::158 ::::::::::::::::::::::::::::::::::160 ::::::::::::::::::::::::::::::::::::3 :::::::::::::::::::::::::141 :::::::::::::::::::::::::::249 :::::::::::::::::::::::::::::::68 :::::::::::::::::::::::170 :::::::::::::::::::::::8 :::::::::::::::::::::::::168 ::::::::::::::::::::::::::::: 175 :::::::::::::::::::175 :::::::::::::::::::::::::::::::::::28 :::::::::::::::::::::::::::::::84 ::::::::::::::::::::::::::::::::175 ::::::::::::::::::::::::::::::::158 ::::::::::::::::::::::::::::: 186 ::::::::::::::::::::::::::95 ::::::::::::::::::::::::::::266,273 :::::::::::::::::::::::::::4 :::::::::::::::::::::::::::::::76,177 :::::::::::::::::::::::::::::76,170 ::::::::::::::::::::::::::::::::117,130 ::::::::::::::::::::::::: 118,313 ::::::::::::::::::::::::::::118,313 :::::::::::::::::::::::::::::::47,130 ::::::::::::::::::::::::::::::6 ::::::::::::::::::::::::::::: 162 ( ) ::::::::::::326 ::::::::::::::::::::::::::::40,89,125 ::::::::::::::::::::::::::::::::::260 :::::::::::::::::::::::::::::::::14 :::::::::::::::::::::::::::::::::46 ( ) :::::::::::::::::::::::::281 ( ) ::::::::::::::::::163 - - :::::::::::::::281 ::::::::::::::::::::::::::::::::248 ::::::::::::::::::::::::::55,56,142 :::::::::::::::::::::::::::::::::::::286 ::::::::::::::::::::::::::::::::::::211
342 ::::::::::::::::::::::::::::: 160 :::::::::::::::::::::::::::138 :::::::::::::::::::::::::::::30,31,35 list? pair? ::::::::::::::::::35 :::::::::::::::::::::::::::::::34 ::::::::::::::::::::::::35 :::::::::::::::::::::::::::: 32 Lisp :::::::::::::::::::::::::::::::::: 10,32 :::::::::::::::::::::::::::: 18 :::::::::::::::::::::::::::::::::18 ::::::::::::::::::::::::::::::::180 :::::::::::::::::::::::::326 :::::::::::::::::::::::::::::::::::47 :::::::::::::::::::::::::::210 ::::::::::::::::::::::::::::::::::5 let ( ) :::::::::::::::::::::::::::144 REP ::::::::::::::::::::::::281,282 ::::::::::::::::::::::::::::::::234 ::::::::::::::::::::::::::::::::::234 ::::::::::::::::::::::::::::: 234 ::::::::::::::::::::::::::::::::23,69 :::::::::::::::::::::::::::::::::::16 ::::::::::::::::::::::::::::17,23 :::::::::::::::::::::::::::::::::17 :::::::::::::::::::::::::::::::18 :::::::::::::::::::::::::::::::::17 :::::::::::::::::::::::::2 ::::::::::::::::::::::::::::::::::::290 ( ) :::::::::::::::::::: 162 ::::::::::::::::::::::::::::::134,135 ::::::::::::::::::::::::::::::::158 ( ) ::::::::::::::::::::::::::::80 :::::::::::::::::::::::::::::::49 ( ) ::::::::::::::171 ( ) :::::::::::::::::::: 170 "" :::::::::::::::::::::::::::::::::::::::47 " ::::::::::::::::::::::::::::::::::::47,132 ' ::::::::::::::::::::::::::::::::30,240,315 * ::::::::::::::::::::::::::::::::::::40,319 + ::::::::::::::::::::::::::::::::::::40,319,@ ::::::::::::::::::::::::::::::::::240,316, :::::::::::::::::::::::::::::::::::240,316 - ::::::::::::::::::::::::::::::::::::40,319 -ci :::::::::::::::::::::::::::::::::::::119 scm :::::::::::::::::::::::::::::::::78,178 / ::::::::::::::::::::::::::::::::::::40,319 ; :::::::::::::::::::::::::::::::::::::::105 <= :::::::::::::::::::::::::::::::::::43,318 < ::::::::::::::::::::::::::::::::::::43,318 = ::::::::::::::::::::::::::::::::::::43,318 >= :::::::::::::::::::::::::::::::::::43,319 > ::::::::::::::::::::::::::::::::::::43,318 ` :::::::::::::::::::::::::::::::::::240,316 A abort :::::::::::::::::::::::::::::::::: 325 abs ::::::::::::::::::::::::::::::::::41,319 abstract data type :::::::::::::::::::::::94 acos :::::::::::::::::::::::::::::::::47,320 actual argument :::::::::::::::::::::::::54 Ada :::::::::::::::::::::::::::::::::::::10 algorithm :::::::::::::::::::::::::::::::205 alist ::::::::::::::::::::::::::::::::::::234 and ::::::::::::::::::::::::::::::::::64,316 angle :::::::::::::::::::::::::::::: 127,320 API ::::::::::::::::::::::::::::::::::::112 append ::::::::::::::::::::::::::::::37,317 application program :::::::::::::::::::::::7 apply :::::::::::::::::::::::::: 233,295,323 argument ::::::::::::::::::::::::::::::::54 asin :::::::::::::::::::::::::::::::::47,320 assembly language :::::::::::::::::::::::: 7 assoc :::::::::::::::::::::::::::::: 235,318 association list ::::::::::::::::::::::::::234 assq ::::::::::::::::::::::::::::::::234,318 assv ::::::::::::::::::::::::::::::::234,318 AT&T ::::::::::::::::::::::::::::::::::::9 atan :::::::::::::::::::::::::47,248,249,320 B #b ::::::::::::::::::::::::::::::::::::::128 back quote ::::::::::::::::::::::::::::::240 \#backspace :::::::::::::::::::::::::::314 Backus-Naur form ::::::::::::::::::::::269 begin ::::::::::::::::::::::::::::::::63,316 \#bel :::::::::::::::::::::::::::::::::: 118 bignum :::::::::::::::::::::::::::::::::263 binary number ::::::::::::::::::::::::::::4 binding :::::::::::::::::::::::::::::141,290 bit ::::::::::::::::::::::::::::::::::::::::3
343 BNF ::::::::::::::::::::::::::::::::::::269 boolean? ::::::::::::::::::::::::::::39,317 boolean ::::::::::::::::::::::::::::::::::38 bubble sort :::::::::::::::::::::::::::::204 buer ::::::::::::::::::::::::::::::::73,168 C C ::::::::::::::::::::::::::::::::::::::::10 caaaar ::::::::::::::::::::::::::::::::::33 caaadr ::::::::::::::::::::::::::::::::::33 caaar ::::::::::::::::::::::::::::::::::::33 caadar ::::::::::::::::::::::::::::::::::33 caaddr ::::::::::::::::::::::::::::::::::33 caadr ::::::::::::::::::::::::::::::::::::33 caar :::::::::::::::::::::::::::::::::33,317 cadaar ::::::::::::::::::::::::::::::::::33 cadadr ::::::::::::::::::::::::::::::::::33 cadar ::::::::::::::::::::::::::::::::::::33 caddar ::::::::::::::::::::::::::::::::::33 cadddr ::::::::::::::::::::::::::::::::::33 caddr ::::::::::::::::::::::::::::::::::::33 cadr :::::::::::::::::::::::::::::::::33,317 call-with-current-continuation : 242,323 call-with-input-file :::::::::::::138,323 call-with-output-file ::::::::::::138,323 car part ::::::::::::::::::::::::::::::::::34 car ::::::::::::::::::::::::::::::::::::::32 car :::::::::::::::::::::::::::::::::::::: 90 car :::::::::::::::::::::::::::::::::::::317 carriage return ::::::::::::::::::::::::::120 case ::::::::::::::::::::::::::::143,235,316 cdaaar ::::::::::::::::::::::::::::::::::33 cdaadr ::::::::::::::::::::::::::::::::::33 cdaar ::::::::::::::::::::::::::::::::::::33 cdadar ::::::::::::::::::::::::::::::::::33 cdaddr ::::::::::::::::::::::::::::::::::33 cdadr ::::::::::::::::::::::::::::::::::::33 cdar :::::::::::::::::::::::::::::::::::::33 cddaar ::::::::::::::::::::::::::::::::::33 cddadr ::::::::::::::::::::::::::::::::::33 cddar ::::::::::::::::::::::::::::::::::::33 cdddar ::::::::::::::::::::::::::::::33,317 cddddr ::::::::::::::::::::::::::::::33,317 cdddr ::::::::::::::::::::::::::::::::::::33 cddr :::::::::::::::::::::::::::::::::::::33 cdr part ::::::::::::::::::::::::::::::::: 34 cdr ::::::::::::::::::::::::::::::::::32,317 ceiling :::::::::::::::::::::::::::::41,320 char->integer :::::::::::::::::::::118,321 char-alphabetic? :::::::::::::::::120,321 char-ci<=? ::::::::::::::::::::::::119,321 char-ci<? ::::::::::::::::::::::::: 119,321 char-ci=? ::::::::::::::::::::::::: 119,321 char-ci>=? ::::::::::::::::::::::::119,321 char-ci>? ::::::::::::::::::::::::: 119,321 char-downcase :::::::::::::::::::::121,322 char-lower-case? :::::::::::::120,200,321 char-numeric? :::::::::::::::::::::120,321 char-ready? :::::::::::::::::::::::137,324 char-upcase :::::::::::::::::::121,200,321 char-upper-case? :::::::::::::::::120,321 char-whitespace? :::::::::::::::::120,321 char<=? ::::::::::::::::::::::::::::119,321 char<? :::::::::::::::::::::::::::::119,321 char=? :::::::::::::::::::::::::::::119,321 char>=? ::::::::::::::::::::::::::::119,321 char>? :::::::::::::::::::::::::::::119,321 char? ::::::::::::::::::::::::::::::120,321 character code ::::::::::::::::::::::::::118 character :::::::::::::::::::::::::::::::117 chdir :::::::::::::::::::::::::::::::::: 326 close-input-port ::::::::::::::::: 134,324 close-output-port ::::::::::::::::135,324 close ::::::::::::::::::::::::::::::::::::105 compcompliers :::::::::::::::::::::::::333 compiler :::::::::::::::::::::::::::::::::12 completion ::::::::::::::::::::::::::::::164 complex? :::::::::::::::::::::::::::126,318 complex :::::::::::::::::::::::::::::40,125 compound procedure :::::::::::::::::::::53 computer :::::::::::::::::::::::::::::::::1 cond-clause ::::::::::::::::::::::::::::::62 cond ::::::::::::::::::::::::::38,61,235,316 conquer :::::::::::::::::::::::::::::::::207 cons :::::::::::::::::::::::::::::33,236,317 constant ::::::::::::::::::::::::::::125,131 continuation ::::::::::::::::::::::::::::241 control key :::::::::::::::::::::::::::::::79 controle key :::::::::::::::::::::::::::: 157 cos ::::::::::::::::::::::::::::::::::46,320 CPU ::::::::::::::::::::::::::::::::::::::3 current output port :::::::::::::::::::::134 current-input-port :::::::::::::::135,324 current-output-port ::::::::::::::135,324 cursor :::::::::::::::::::::::::::::::::17,74 cut and paste :::::::::::::::::::::::::::162
344 cxr ::::::::::::::::::::::::::::::::::::: 33 cxxr ::::::::::::::::::::::::::::::::::::33 cxxxr ::::::::::::::::::::::::::::::::::33 D #d ::::::::::::::::::::::::::::::::::::::128 data abstraction :::::::::::::::::::::::::94 decode-universal-time ::::::::::::::::325 define ::::::::::::::::::::::::::: 27,53,315 defined? :::::::::::::::::::::::::::::::325 defun :::::::::::::::::::::::::::::::::::179 \#del :::::::::::::::::::::::::::::::::: 118 delay :::::::::::::::::::::::::::::::::: 316 delete-file :::::::::::::::::::::::139,325 delete :::::::::::::::::::::::::::::::::::160 denominator :::::::::::::::::::::::127,319 derivation :::::::::::::::::::::::::::::: 269 devide and conquer :::::::::::::::::::::207 devide ::::::::::::::::::::::::::::::::::207 display ::::::::::::::48,63,121,132,134,324 do ::::::::::::::::::::::::::::::::::229,316 dotted notation ::::::::::::::::::::::::::34 double quotation ::::::::::::::::::::::::132 dynamic scoping ::::::::::::::::::::::::141 E #e ::::::::::::::::::::::::::::::::::::::128 edior ::::::::::::::::::::::::::::::::::: 173 editing buer ::::::::::::::::::::::::::::73 editor :::::::::::::::::::::::::::::::::12,73 ELK :::::::::::::::::::::::::::::::::21,333 else clause ::::::::::::::::::::::::::::::143 Emacs editor ::::::::::::::::::::::::::: 157 empty list ::::::::::::::::::::::::::::::::32 end-of-le object ::::::::::::::::::::::::137 environment ::::::::::::::::::::::::142,291 eof-object? :::::::::::::::::::::::137,324 eq? :::::::::::::::::::::::50,52,234,236,317 equal? :::::::::::::::::::50,53,235,236,317 eqv? ::::::::::::::::::::::50,51,234,236,317 errobj :::::::::::::::::::::::::::::::::325 error ::::::::::::::::::::::::::::::::91,325 escape key ::::::::::::::::::::::::::::::157 evaluation :::::::::::::::::::::::::::::::27 even? :::::::::::::::::::::::::::::::43,319 exact number ::::::::::::::::::::::::::::45 exact->inexact :::::::::::::::::::::46,320 exact? ::::::::::::::::::::::::::::::45,318 exactness ::::::::::::::::::::::::::::::::45 exp ::::::::::::::::::::::::::::::::::46,320 exponent ::::::::::::::::::::::::::::::: 128 expression :::::::::::::::::::::::::::::::26 expt :::::::::::::::::::::::::::::::::47,320 extension ::::::::::::::::::::::::::::::::78 F #f :::::::::::::::::::::::::::::::::::38,128 factorial ::::::::::::::::::::::::::::::::148 le name ::::::::::::::::::::::::::::::: 133 file-exists? ::::::::::::::::::::::139,325 file-position? ::::::::::::::::::::::::326 file-set-position ::::::::::::::::::::326 le :::::::::::::::::::::::::::::::::::::::12 oating-point representation ::::::::::::128 floor ::::::::::::::::::::::::::::41,260,320 flush-output-port ::::::::::::::::::::139 for-each :::::::::::::::::::::::::::230,323 force-output ::::::::::::::::::139,283,326 force :::::::::::::::::::::::::::::: 316,323 form feed :::::::::::::::::::::::::::::::120 formal argument :::::::::::::::::::::::::54 Fortran ::::::::::::::::::::::::::::::::::10 frame :::::::::::::::::::::::::::::::::::290 FTP ::::::::::::::::::::::::::::::::333,335 fundermental mode ::::::::::::::::::::::76 G garbage collection :::::::::::::::::::::::307 gc ::::::::::::::::::::::::::::::::::::::325 gcd ::::::::::::::::::::::::::::::::::42,319 get-decode-time :::::::::::::::::::::::325 get-internal-real-time ::::::::::::::325 get-internal-run-time ::::::::::::::::325 get-universal-time :::::::::::::::::::325 getenv :::::::::::::::::::::::::::::::::325 grammer ::::::::::::::::::::::::::::::::268 H high level language :::::::::::::::::::::::10 history ::::::::::::::::::::::::::::::::: 180 I #i ::::::::::::::::::::::::::::::::::::::128 if ::::::::::::::::::::::::::::::::38,60,315 imag-part ::::::::::::::::::::::::::127,320
345 indent (dene) ::::::::::::::::::::::::::150 indent ::::::::::::::::::::::::::::::::::149 index :::::::::::::::::::::::::::::::::::124 inexact number ::::::::::::::::::::::::::45 inexact->exact :::::::::::::::::::::45,320 inexact? ::::::::::::::::::::::::::::45,318 innite loop ::::::::::::::::::::::::::::::84 information hiding :::::::::::::::::::::::94 inode :::::::::::::::::::::::::::::::::::326 input port ::::::::::::::::::::::::::::::134 input-port? :::::::::::::::::::::::135,323 Input/Output device ::::::::::::::::::::::3 input/output :::::::::::::::::::::::::::133 integer->char :::::::::::::::::::::119,321 integer? ::::::::::::::::::::::::44,126,318 integer :::::::::::::::::::::::::::::::40,125 internal denition :::::::::::::::::::::::139 internal-time-units-per-second :::::325 interpreter :::::::::::::::::::::::::::::::12 I/O device ::::::::::::::::::::::::::::::::3 isatty? ::::::::::::::::::::::::::::::::326 K kill buer :::::::::::::::::::::::::::::::160 kill :::::::::::::::::::::::::::::::::::::160 L #l ::::::::::::::::::::::::::::::::::::::128 expression :::::::::::::::::::::::::::::55 lambda ::::::::::::::::::::::::::::::55,315 language processor :::::::::::::::::::::::11 lcm ::::::::::::::::::::::::::::::::::42,319 length ::::::::::::::::::::::::::::::37,317 let* :::::::::::::::::::::::::::::::::60,316 let ::::::::::::::::::::::::::::::58,145,316 letrec :::::::::::::::::::::::::::::146,316 lexical scoping ::::::::::::::::::::::::::141 line feed ::::::::::::::::::::::::::::::::120 link count :::::::::::::::::::::::::::::: 326 Lisp :::::::::::::::::::::::::::::::::::::10 list notation ::::::::::::::::::::::::::::: 34 list->string ::::::::::::::::::::::122,322 list->vector ::::::::::::::::::::::125,323 list-file ::::::::::::::::::::::::::::::325 list-ref ::::::::::::::::::::::::::::37,318 list-tail :::::::::::::::::::::::::::37,318 list? :::::::::::::::::::::::::::::::35,317 list :::::::::::::::::::::::::::::::::30,31,35 list :::::::::::::::::::::::::::::::::36,317 load :::::::::::::::::::::::::::::::::: 23,69 load :::::::::::::::::::::::::::::::::86,324 local variable :::::::::::::::::::::::::::: 58 log ::::::::::::::::::::::::::::::::::46,320 login name :::::::::::::::::::::::::::::::18 login :::::::::::::::::::::::::::::::::::::17 logout :::::::::::::::::::::::::::::::::::23 loop invariant :::::::::::::::::::::::::::210 M magnitude ::::::::::::::::::::::::::127,320 main memory :::::::::::::::::::::::::::::3 make-polar :::::::::::::::::::::::::127,320 make-rectangular ::::::::::::::::: 127,320 make-string :::::::::::::::::::::::130,322 make-vector :::::::::::::::::::122,123,323 mantissa ::::::::::::::::::::::::::::::::128 map :::::::::::::::::::::::::::::::::232,323 mark :::::::::::::::::::::::::::::::::::160 max ::::::::::::::::::::::::::::::::::40,319 MC6809 ::::::::::::::::::::::::::::::::::6 member :::::::::::::::::::::::::::::236,318 memory cell :::::::::::::::::::::::::::::::3 memq ::::::::::::::::::::::::::::::::235,318 memv ::::::::::::::::::::::::::::::::236,318 message passing ::::::::::::::::::::::::::95 message :::::::::::::::::::::::::::::::: 186 meta key ::::::::::::::::::::::::::::::: 158 Microsoft :::::::::::::::::::::::::::::::::9 min ::::::::::::::::::::::::::::::::::40,319 MIT Scheme :::::::::::::::::::::::::::::21 mode line ::::::::::::::::::::::::::::::::76 mode ::::::::::::::::::::::::::::::::76,177 modulo ::::::::::::::::::::::::::::::42,319 most-negative-fixnum :::::::::::::::::325 most-positive-fixnum :::::::::::::::::325 MS-DOS ::::::::::::::::::::::::::::::::::9 multiple buers :::::::::::::::::::::::::168 multiprogramming ::::::::::::::::::::::::8 multitasking ::::::::::::::::::::::::::::::8 mutual recursion :::::::::::::::::::::::::67 N named let :::::::::::::::::::::::::::::::144 native language :::::::::::::::::::::::::::5 negative? :::::::::::::::::::::::::::43,319 newline :::::::::::::::::::::::::::::::::63
346 \#newline ::::::::::::::::::::::::::::::122 newline ::::::::::::::::::::::::::::::::133 \#newline ::::::::::::::::::::::::::199,314 newline ::::::::::::::::::::::::::::::::324 Ng editor :::::::::::::::::::::::::::::::157 NGSCM :::::::::::::::::::::::::::::17,334 \#nl ::::::::::::::::::::::::::::::::::::199 non-local exit :::::::::::::::::::::::::::244 not ::::::::::::::::::::::::::::::::::39,317 null string :::::::::::::::::::::::::::::::47 null? :::::::::::::::::::::::::::::::32,317 \#null :::::::::::::::::::::::::::::::::314 number->string ::::::::::::::::::::129,321 number? :::::::::::::::::::::::::44,126,318 number :::::::::::::::::::::::::::::::::125 numbers :::::::::::::::::::::::::::::::::40 numerator ::::::::::::::::::::::::::127,319 O #o ::::::::::::::::::::::::::::::::::::::128 object ::::::::::::::::::::::::::::::::::186 odd? :::::::::::::::::::::::::::::::: 43,319 open-input-file :::::::::::::::::::134,324 open-output-file ::::::::::::::::: 134,324 open ::::::::::::::::::::::::::::::::::::105 operating system ::::::::::::::::::::::::::8 or :::::::::::::::::::::::::::::::::::65,316 output port :::::::::::::::::::::::::::::134 output-port? ::::::::::::::::::::::::::324 outut-port? :::::::::::::::::::::::::::135 P \#page :::::::::::::::::::::::::::::::::314 pair? :::::::::::::::::::::::::::::::35,317 pair :::::::::::::::::::::::::::::::::::32,33 parsing :::::::::::::::::::::::::::::::::270 Pascal :::::::::::::::::::::::::::::::::::10 password :::::::::::::::::::::::::::::::: 18 PC-Scheme :::::::::::::::::::::::::::::334 peek-char ::::::::::::::::::::::::::137,324 point :::::::::::::::::::::::::::::::::::158 port ::::::::::::::::::::::::::::::::::::134 positive? :::::::::::::::::::::::::::43,319 primitive procedure ::::::::::::::::::::::53 procedure? :::::::::::::::::::::55,242,323 procedure ::::::::::::::::::::::::::::::::55 program counter ::::::::::::::::::::::::::6 program ::::::::::::::::::::::::::::::::::1 programming language :::::::::::::::::::10 prompt ::::::::::::::::::::::::::::::::::18 pseudo random number :::::::::::::::::211 Q quasiquotations :::::::::::::::::::::::::240 quasiquote :::::::::::::::::::::::::240,316 quick sort :::::::::::::::::::::::::::::::204 quit ::::::::::::::::::::::::::::::::::::324 quote ::::::::::::::::::::::::::::::30,90,99 quote :::::::::::::::::::::::::::::::::: 315 quotient ::::::::::::::::::::::::::::42,319 R random number :::::::::::::::::::::::::211 rational? ::::::::::::::::::::::::: 126,318 rational :::::::::::::::::::::::::::40,89,125 rationalize :::::::::::::::::::::::127,320 read-char ::::::::::::::::::::::137,199,324 read-line! ::::::::::::::::::::::::::::325 read-line ::::::::::::::::::::::::::::::325 read ::::::::::::::::::::::::131,137,218,324 real-part ::::::::::::::::::::::::::127,320 real? :::::::::::::::::::::::::::44,126,318 real ::::::::::::::::::::::::::::::::::40,125 recursion ::::::::::::::::::::::::65,66,67,98 region ::::::::::::::::::::::::::::::::::160 register :::::::::::::::::::::::::::::::::::5 remainder :::::::::::::::::::::::::::42,319 rename-file :::::::::::::::::::::::139,326 REP loop :::::::::::::::::::::::::::::::281 replace ::::::::::::::::::::::::::::::::: 165 return character ::::::::::::::::::::::::199 \#return :::::::::::::::::::::::::::::::314 reverse :::::::::::::::::::::::::::::37,317 round ::::::::::::::::::::::::::::::::41,320 S #s ::::::::::::::::::::::::::::::::::::::128 save :::::::::::::::::::::::::::::::::::::73 scheme mode :::::::::::::::::::::::::::: 76 Scheme ::::::::::::::::::::::::::::::10,333 SCM ::::::::::::::::::::::::::::::20,21,334 search ::::::::::::::::::::::::::::::::::165 selection sort ::::::::::::::::::::::::::: 205 self-evaluating ::::::::::::::::::::::::::: 38
347 semantics :::::::::::::::::::::::::::::::270 set! :::::::::::::::::::::::::::::::: 28,316 set-car! :::::::::::::::::::::::::::238,317 set-cdr! :::::::::::::::::::::::::::238,317 side eect ::::::::::::::::::::::::::::::::64 sin ::::::::::::::::::::::::::::::::::46,320 SOID :::::::::::::::::::::::::::::::::::334 sorting ::::::::::::::::::::::::::::::::::204 \#space ::::::::::::::::::::::::::::::::118 space :::::::::::::::::::::::::::::::::::120 \#space ::::::::::::::::::::::::::::::::314 special form ::::::::::::::::::::::::::::::28 sqrt :::::::::::::::::::::::::::::::::47,320 stack :::::::::::::::::::::::::::::::::::: 68 stat ::::::::::::::::::::::::::::::::::::326 static binding :::::::::::::::::::::::::::141 straight selection sort :::::::::::::::::::205 string->list ::::::::::::::::::::::122,322 string->number ::::::::::::::::::::129,321 string->symbol ::::::::::::::::::::131,318 string-append ::::::::::::::::::::::48,322 string-ci<=? :::::::::::::::::::::::49,322 string-ci<? ::::::::::::::::::::::::49,322 string-ci=? ::::::::::::::::::::::::49,322 string-ci>=? :::::::::::::::::::::::49,322 string-ci>? ::::::::::::::::::::::::49,322 string-copy :::::::::::::::::::::::131,322 string-fill! ::::::::::::::::::::::131,323 string-length ::::::::::::::::::::::48,322 string-ref :::::::::::::::::::::::::130,322 string-set! :::::::::::::::::::::::130,322 string<=? :::::::::::::::::::::::::::49,322 string<? ::::::::::::::::::::::::::::49,322 string=? ::::::::::::::::::::::::::::49,322 string>=? :::::::::::::::::::::::::::49,322 string>? ::::::::::::::::::::::::::::49,322 string? :::::::::::::::::::::::::::::48,322 string ::::::::::::::::::::::::::::::::::::47 string :::::::::::::::::::::::::::::130,322 subproblem :::::::::::::::::::::::::::::207 substring :::::::::::::::::::::::::::48,322 symbol->string ::::::::::::::::::::131,318 symbol? :::::::::::::::::::::::::::::31,318 symbol ::::::::::::::::::::::::::::29,31,131 syntax ::::::::::::::::::::::::::::::::::268 system program :::::::::::::::::::::::::::8 system :::::::::::::::::::::::::::::::::325 systems programming :::::::::::::::::::::7 T #t :::::::::::::::::::::::::::::::::::::::38 \#tab :::::::::::::::::::::::::::::::::: 118 tab :::::::::::::::::::::::::::::::::::::120 \#tab :::::::::::::::::::::::::::::::::: 314 tail recursive :::::::::::::::::::::::::::::68 tan ::::::::::::::::::::::::::::::::::46,320 tan,1 x :::::::::::::::::::::::::::::::::248 tan x ::::::::::::::::::::::::::::::::::: 248 terms :::::::::::::::::::::::::::::::::: 325 text ::::::::::::::::::::::::::::::::::::::73 top level denition ::::::::::::::::::::::139 transcript-off :::::::::::::::::::::69,324 transcript-on ::::::::::::::::::::::69,324 truncate ::::::::::::::::::::::::::::41,320 U Unix :::::::::::::::::::::::::::::::::::9,76 unquote-splicing ::::::::::::::::: 240,316 unquote ::::::::::::::::::::::::::::240,316 URL ::::::::::::::::::::::::::::::::::::333 V variable ::::::::::::::::::::::::::::::::::27 vector->list ::::::::::::::::::::::125,323 vector-fill! ::::::::::::::::::::::124,323 vector-length :::::::::::::::::::::123,323 vector-ref :::::::::::::::::::::::::123,323 vector-set! :::::::::::::::::::::::123,323 vector? ::::::::::::::::::::::::::::124,323 vector ::::::::::::::::::::::::::::::::::122 vector :::::::::::::::::::::::::::::::::323 VSCM ::::::::::::::::::::::::::::::::::334 W waterfall model ::::::::::::::::::::::::::14 whitespace ::::::::::::::::::::::::::::::120 window ::::::::::::::::::::::::::::::74,170 with-input-from-file :::::::::::::138,324 with-output-to-file ::::::::::::::138,324 word ::::::::::::::::::::::::::::::::::::::4 write-char :::::::::::::::::121,134,199,324 write-line :::::::::::::::::::::::::::::325 write :::::::::::::::::::::: 121,132,134,324 WWW ::::::::::::::::::::::::::::::::: 333
348 X #x ::::::::::::::::::::::::::::::::::::::127 Y yank ::::::::::::::::::::::::::::::::::::162 Z zero? :::::::::::::::::::::::::::::::43,319