Copy Free \Scheme " Copy Free \Scheme " 2 (2a) (2b) (2c) 3 (3a) (The Internet) (3b) (6a) (6b) (6c) (6d) Scheme

Size: px
Start display at page:

Download "Copy Free \Scheme " Copy Free \Scheme " 2 (2a) (2b) (2c) 3 (3a) (The Internet) (3b) (6a) (6b) (6c) (6d) Scheme"

Transcription

1 Scheme ( ) c1993, 1994, 1995, 1996 Hirotsugu Kakugawa : ( ) kakugawa@sehiroshima-uacjp

2 Copy Free \Scheme " Copy Free \Scheme " 2 (2a) (2b) (2c) 3 (3a) (The Internet) (3b) (6a) (6b) (6c) (6d) Scheme

3 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 2 12 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 13 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 14 2 Scheme : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Scheme (NGSCM) : : : : : : : : : : : : : : : : : : : Scheme : : : : : : : : : : : : : : : : : : : : : Mule : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Scheme : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 23 3 Scheme ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( 1) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 40 1

4 2 363 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : let : : : : : : : : : : : : : : : : : : : : : : : : : : : let* : : : : : : : : : : : : : : : : : : : : : : : : : : ( 1) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : if : : : : : : : : : : : : : : : : : : : : : : : : : : : cond : : : : : : : : : : : : : : : : : : : : : : : : : : begin : : : : : : : : : : : : : : : : : : : : : : : and or : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 69 4 NGSCM : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : NGSCM : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : NGSCM : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Mule : : : : : : : : : : : : : : : : : : : : : : : : : : : : Scheme : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 114

5 6 Scheme ( ) ( 2) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( 2) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : case : : : : : : : : : : : : : : : : : : : : : : : : : : let : : : : : : : : : : : : : : : : : : : : : letrec : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : NGSCM NGSCM : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Scheme Scheme Scheme Interaction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : NGSCM Scheme : : : : : : : : : : : : : : : : : : : : 182 3

6 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Scheme ( ) ( 3) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : do : : : : : : : : : : : : : : : : : : : : : : : : : for-each : : : : : : : : : : : : : : : : : : : : : map : : : : : : : : : : : : : : : : : : : : : : : : : : aplly : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : A : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 244

7 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Scheme : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : REP : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( 1) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : ( 2 ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : ( ) : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 308 A ASCII 313 B Scheme 315 C NGSCM 327 5

8 6 D Scheme 333 D1 Scheme : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 333 D2 FTP : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

9 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 ( )

10 1 (computer) ( ) ( ) ( (program) ) Scheme ( ) ( ) 1

11 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

12 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

13 4 1 p p p p p p p p p p p p 13: (word) ? (binary number) ASCII A ,1,2,

14 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: ( ) ( ) (0 1 ) (native language) Scheme C Fortran ( ) ( ) ( 14 ) (register)

15 6 1 (program counter) ( ) 1 ( ) 2 3 ( 1 ) MC MC

16 LDX #100 LDA,X ADDA 1,X STA 2,X 1 LDX #100 X 100 X , , LDX # LDA,X X A X A ADDA 1,X X 1 ( X ) A A X 2 ( X ) A ( ) (application program) 3

17 8 1 (system program) 131 (operating system)? 1 (multitasking) ( (multiprogramming)) 001 1

18 13 9 Unix 1960 AT&T (American Telephone & Telegram) MS-DOS MS-DOS Microsoft ( 1 0 1!)

19 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 MC6809 ( MC6809 ) 132(a), (b) Scheme, Pascal 15 ( ) ( )

20 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 ( CPU C )

21 (compiler) (interpreter) ( ) ( ) 133 (editor) (le) 5

22 13 13 (41 )

23 (waterfall model) 1 2

24 Alan W Biermann ( ), \,", 1993 M A Arbib, A J Kfoury, R N Moll (,, ), \," Information&Computing-1,, 1984 P AKidwell, P ECeruzzi ( ), \,", 1995

25 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

26 2 Scheme Scheme NGSCM 1 Scheme Scheme Scheme Unix Unix 1 ( ) : MS-DOS : Unix login: (cursor) 1 NGSCM Scheme NGSCM Appendix D 17

27 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

28 22 Scheme (NGSCM) Scheme (NGSCM) Scheme NGSCM % ngscm RET 21 NGSCM Version 332 of 01/20/96 on owl (FreeBSD 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, 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

29 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, 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 )

30 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 > > Scheme Scheme Scheme

31 22 2 Scheme Scheme ( ) Scheme ( ) + ( ) ( 20 26) ( ) DEL C-j ( j ) C-j (Scheme DEL BS ( C-j RET ) > ( ) C-j ;Evaluation took 0 msec (0 in gc) 0 cons work 56 ( ) ;Evaluation took 0 msec (0 in gc) 0 cons work ( ) 56 (= ) > : > ( ) ;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 >

32 25 23 > (+ 3 (* 2 4)) C-j ;Evaluation took 0 msec (0 in gc) 0 cons work 11 3+(2 4) (* 2 4) 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

33 24 2 Scheme Scheme 1 ( ) 2 (* 4 6) 3 (- 10 2) 4 (+ (* 2 3) 4) 5 (* (+ 1 2) (+ 3 4)) 6 (/ 100 (+ 1 1))

34 3 Scheme ( ) Scheme Scheme Scheme Scheme (NGSCM Mule ) 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

35 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) 8 8 Scheme (expression) 2001 ( ) (+ 3 5) (* ) > (+ (* 3 4) (* 2 9)) 30 (+ (* 3 4) (* 2 9)) (* 3 4) (* 2 9) ( ) 30

36 32 27 > (+ (* (- 5 4) (- 3 1)) 10) 12 (+ (* (- 5 4) (- 3 1)) 10) = (+ (* 1 2) 10) = (+ 2 10) = 12 Scheme (Scheme (evaluation) ) ( ) ( ) (a 0 a 1 a 2 a n ) a 0,,a n b 0,,b n b 1 ; :::; b n b 0 b (variable) ( ) define } (define h i h i) h i h i income 1 a0 Scheme + +

37 28 3 Scheme ( ) > (define income ) #<unspecified> > income > (+ income 10000) #<unspecified> 2 define ( income) > (define expense ( )) #<unspecified> > expense (define expense ( )) expense ( ) expense expense (define ) define define Scheme (special form) ( ) set! } (set! h i h i) h i h i define set! tax 2 Scheme (define income ) define NGSCM #<unspecified> Scheme ( )

38 33 29 > tax Error: unbound variable: tax tax tax set! > (set! tax 15000) Error: unbound variable: tax define set! > (define tax 10000) #<unspecified> > tax > (set! tax 15000) #<unspecified> > tax : (define 'age 17) 'age (quote age) (define (quote age) 17) quote 'age quote (quote Scheme ) 33 Scheme (symbol)

39 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 )

40 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 )) (a (ba bb) (ca (cba cbb) cc) d) 3 -A

41 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 ( ) ( ) ( ) ( ) 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

42 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 ( )

43 34 3 Scheme ( ) 2 3 (a) (b) (cons 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))

44 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)

45 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 ( ) (cons 1 (cons 2 (cons 3 (cons 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 )

46 35 37 > (define a 100) #<unspecified> > (define b 200) #<unspecified> > (list ) ( ) > (list a b) ( ) > (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))

47 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 ( ) (boolean) #t #f if cond 11 (selfevaluating) > #t #t Scheme #f

48 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

49 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

50 36 ( 1) 41 } (abs x) x } (floor x) x } (ceiling x) x } (truncate x) } (round x) > (+ 2 4) 6 6 > (+ 2 40) > (- 2 3) -1 > (- 3) -3 > (* 30 45) +135 > (/ 10 5) 2 > (/ 10 50) +20 > (max ) 23 > (min ) 2 > (abs -8) 8 > (floor 103) 10 > (floor -103)

51 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

52 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

53 44 3 Scheme ( ) > (< 3 4 5) #t > (<= ) #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)

54 36 ( 1) 45 #t > (integer? 82) #f > (real? 82) #t > (integer? 2) #t > (integer? 20) #t > (real? 100) #t ( ) : :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

55 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) (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

56 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" \ \" \ =Y \ =Y

57 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 "")

58 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"

59 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", = = 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 ( )

60 h 1 ih 2 i ( ) #t #f 2 #t > (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 ( )

61 52 3 Scheme ( ) > (eqv? 'abc 'abc) #t > (eqv? 'foo 'bar) #f > (eqv? '() '()) #t > (eqv? 16 16) #t > (eqv? 16 (* 2 8)) #t > (eqv? ) #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

62 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? ) #t > (equal? 1 10) #f 38 (primitive procedure) (compound procedure) define (compound procedure)

63 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 add > (define (distance x y) (sqrt (+ (* x x) (* y y)))) #<unspecified> > (distance 1 1) > (distance 2 4)

64 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

65 56 3 Scheme ( ) (lambda (n) (+ n 1)) > (add1 10) 11 add > (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

66 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 ) s ( ) > (foo 1 2) 2 > (foo ) 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 :

67 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 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

68 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

69 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) 3101 if if 2 foo n 0 zero non-zero (define (foo n) (if (zero? n) 'zero 'non-zero))

70 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 cond cond (define (score n) (cond ((<= n 50) 'fail) ((< n 70) 'poor) ((< n 80) 'fair) (else 'excellent))) 19 Scheme 20

71 62 3 Scheme ( ) score n 50 fail poor 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)

72 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

73 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 ( )

74 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

75 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

76 (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)

77 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

78 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)

79 70 3 Scheme ( ) (print-sqrt-table 1 10) > (load "sqrt-tablescm") ;loading "prog/sqrt-tablescm" ;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> > ( ) ;Evaluation took 0 msec (0 in gc) 11 cells work, 37 bytes other 6 > (* ) ;Evaluation took 0 msec (0 in gc) 32 cells work, 51 bytes other > (transcript-off) #<unspecified> LOG-FILE transcript-on transcript-off : ;Evaluation took 0 msec (0 in gc) 6 cells work, 37 bytes other #<unspecified> > ( ) ;Evaluation took 0 msec (0 in gc) 11 cells work, 37 bytes other 6 > (* ) ;Evaluation took 0 msec (0 in gc) 32 cells work, 51 bytes other > (transcript-off) transcript-on transcript-off Scheme ( )

80 Scheme Scheme ( ) 6 Scheme Appendix B Scheme

81 72 3 Scheme ( )

82 4 NGSCM Mule Appendix NGSCM , (editor) 1 41 (editing buer) ( (buer) ) (text) (save) 73

83 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 NGSCM 42

84 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 > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 43: NGSCM NGSCM **-NGSCM: qwescm (-EE:fundamental-Scheme) :

85 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

86 44 77 sumscm NGSCM 432 NGSCM % ngscm RET NGSCM C-x C-f 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

87 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) : ngscm sumscm NGSCM % ngscm sumscm RET

88 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

89 80 4 NGSCM 46 ( 47 ) (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) --**-NGSCM: sumscm (-EE:fundamental-Scheme) : sum ) ( Scheme C-x (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

90 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, 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, 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

91 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, 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, 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)

92 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))

93 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 ) C-x C-c NGSCM 441 Mule Unix Mule Scheme 1 Mule % mule sumscm RET 2 3 C-x Scheme C-c

94 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, 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 : 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

95 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

96 5 Scheme : ( addressscm )

97 88 5 * (* ) ( )

98 (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 rat rational

99 ( 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=

100 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

101 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

102 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) > (rat-den t) =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

103 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)

104 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 r 1 r 2 (1) 2 (2) (3) r 1 + r 2 (4)

105 96 5 rat:show > (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

106 * 1=1 1

107 (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

108 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))

109 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

110 (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

111 102 5 ( ) ( ) () () 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 (pooh piglet 2001) 2 ( (owl rabbit)) 0 2 ( ) ( ) 0 (pooh piglet 2001) 2 ( (owl rabbit)) 2

112 ( ) 2 (pooh piglet 2001) 1 ( (owl rabbit)) 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"

113 : 2 94 ( 2: ) ( ) A 1 2 A 3 A 4 5 ( ) (!) ( )

114 53 1: *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 ) ((mayuko ) (misako ) (hikaru ) ) 6 7 ;

115 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

116 53 1: 107 *ADDRESS-BOOK* *ADDRESS-BOOK-STATE* () Misako Mayuko Narimi Chisato : ; (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 ' ) (add-to-address-book 'Narimi ' ) (add-to-address-book 'Mayuko ' ) (add-to-address-book 'Misako ' )) *ADDRESS-BOOK-OPENED*

117 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*

118 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 ( )

119 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 ' ) (add-to-address-book 'Narimi ' ) (add-to-address-book 'Mayuko ' ) (add-to-address-book 'Misako ' )) ;;; ; (define (open-address-book) (set! *ADDRESS-BOOK-STATE* *ADDRESS-BOOK*) (set! *ADDRESS-BOOK-OPENED* #t)) ; (define (close-address-book) (set! *ADDRESS-BOOK-OPENED* #f))

120 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)

121 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

122 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)? > (phone 'Hiroko)? "Not found"

123 ( ) ( read-addres) (94 ( 2: ) ) 53 Scheme cons, car, null? Scheme read-address, lookup-address Scheme 1 show-all 2 phone-to-name

124 53 1: name-to-address 5 age-from-to (age-from-to f t) f t 6 birthday-people ( ) 7 ( ) 8 ** ( ) (1)? (2)? 1 53

125 116 5

126 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

127 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

128 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 /

129 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?

130 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

131 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) 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

132 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 )

133 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

134 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) : :0+0:0i 1:5 1:5+0:0i 62 Scheme

135 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

136 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 (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 #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= a f 16 ( / ) 16 a (= )

137 128 6 Scheme ( ) > #x (10 16) > #x1f 31 2 (#b) 8 (#o) 10 (#d) > #b > #o > #d > > (+ #b10 #o10 #d10 #x10) ( ) Scheme 540e3 54: = 54000:0 1675e-5 167:5 10,5 =0: 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

138 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

139 130 6 Scheme ( ) 614 ( ) "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 } (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"

140 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!

141 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>

142 } (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

143 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

144 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) Pooh Owl

145 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 ( )

146 ( 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

147 138 6 Scheme ( ) read-char read-char char-ready? (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

148 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

149 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))

150 (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) Lisp (Lisp 15 MacLisp ) Scheme Lisp Common Lisp

151 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)

152 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 )

153 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

154 64 ( 2) (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)

155 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)

156 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

157 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 n (factorial) n! 1 n n! =n (n, 1) (n, 2) 2 1 ( 1 n =1 n! = n (n, 1)! n 2

158 ; 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)

159 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 define 2 (define (h i h i) h i) 14

160 (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

161 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)

162 (h i h i h i h i h i h i h i) h i (a),(b),(c) 651(a) b, c (a) (b) (a) (b) S S (c) b c? 651(c) ( )

163 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 '( ) 003) ;; ---> 60 = 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:

164 B W Kernighan, P J Plauger ( ), \ ",,, 1982 B W Kernighan, P J Plauger ( ), \ ",, 1981 F P Brooks Jr ( ), \ ",, 1977 D E Knuth ( ), \ ",, 1994,\ ",, 1985

165 156 6 Scheme ( )

166 7 NGSCM NGSCM NGSCM NGSCM 71 NGSCM 711 NGSCM a a NGSCM b (controle key) (shift key) (tab key) `CTL' `CTRL' `Control' 2 (escape key) ( `ESC' ) 157

167 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 ( ) Eample a x Example a 3 Emacs / Emacs (meta key) 3 Emacs (point)

168 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

169 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

170 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" )

171 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

172 71 NGSCM 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 :

173 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

174 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, bytes other > --**-NGSCM: *scheme* Possible completions are: sumscm sum1scm (-EE:fundamental-Scheme Interaction) NGSCM: *Completions* Find file: sum (-EE:fundamental) : s RET Find file: s TAB Find file: s [No match] 717 (search) (replace) (regular expression) C-s C-r

175 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

176 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

177 168 7 NGSCM MR Buffer Size File *help* 3571 *Buffer List* 0 * *scheme* 529 % qwescm 143 /tmp_mnt/condor/home1/kakugawa/qwescm *scratch* NGSCM: *Buffer List* (-EE:fundamental) : 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

178 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)

179 170 7 NGSCM C-x C-q --**-NGSCM --%%-NGSCM C-x C-q --%%-NGSCM 719 (multiple windows) qwescm *scheme* (window) 2 ( ) C-x 2 2 C-x 0 C-x 1 75 C-x factscm 77

180 71 NGSCM 171 (define (sum n) (if (= n 1) 1 (+ (sum (- n 1)) n))) -----NGSCM: sumscm (-EE:fundamental-Scheme) : 1 C-x o C-x^ M-x shrink-window C-x o C-x^ 1 M-x shrink-window ( ) C-x^ 78 5 C-x^

181 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) : 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) :, factscm

182 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) : 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,, Richard M Stallman (, ), \GNU Emacs ",, Craig A Finseth ( ), \The Craft of Text Editing { {",,

183 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))

184 71 NGSCM 175 > (ave 2 3 4) ;Evaluation took 0 msec (0 in gc) 8 cons work 3 > (power ) ;Evaluation took 0 msec (0 in gc) 8 cons work 7

185 176 7 NGSCM

186 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

187 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*

188 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 )

189 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 ) ( ) (* ) (vector ) 81 M-p ( (vector ) M-p ( (* ) ) M-p M-p M-n 82

190 81 Scheme Scheme Interaction 181 Bug reports, suggestions, requests are welcome Send to > (list ) ( ) > ( ) 15 > (* ) 120 > (vector ) #( ) > --**-NGSCM: *scheme* (-EE:fundamental-Scheme Interaction)-- 81: C-j C-j : NGSCM *scheme* > ( ) 2 1 *scheme* M-p ( *scheme* ) 5 M-p (vector ) M-n

191 182 8 Scheme > (vector ) (1) 1 M-C-p > (* ) (2) M-C-p > (list ) (3) 2 M-C-p > ( ) (4) M-C-n 82: C-c C-p 1 C-c C-n NGSCM Scheme NGSCM Scheme 1 :

192 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

193 184 8 Scheme Interaction

194 Scheme : 185

195 ( ) ( ) (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

196 > (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 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)))

197 > (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

198 > (w1 40) (vending machine) 1 1 ( ) ( ) ( ) ( ) : (define (new-vend stock) (lambda message (cond (h button i h i ) (hstock i h i) (h, i ))))

199 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"

200 pppppppp pppppp 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 )

201 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

202 (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 new-vend (!) vend supply (v 'supply 10) v * 1 1

203

204 ( ) 2 (le name) ( ) 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

205 (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) a b c d "STRING!!" ; a comment line end? (show-s-exp "testdatascm") > (show-s-exp "testdatascm") (a b c) a b

206 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)

207 total)) total total sum-file total 3 numdatascm : sum-file > (num-file "numdatascm") 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

208 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))

209 (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?

210 (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

211 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 ) ( )

212 ("Tanaka Misako" ) ("Nishida Hikaru" ) ("Takahashi Yumiko" ) ("Takata Mayuko" ) ("Yoshida Mayuko" ) ("Yoshida Makiko" ) ("Amuro Namie" ) ("Uchida Yuki" ) 11 * ?

213 ( ) (sorting) ( ) (`system' `a' `r' ) (bubble sort) (quick sort) : i a i i a i a i+1 a i <a i+1 i i

214 i a i a i+1 ( ) (algorithm) 6 ( ) (selection sort) ( (straight selection sort)) (bubble sort) 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 set! vector-set!! Scheme ( )!

215 (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 )) #( ) > (bubble-sort! (vector 1 2)) #(2 1) > (bubble-sort! (vector 100)) #(100) 932 (quick sort)

216 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: ( 1) ( 2 2 ) ( ) 2 (devide and conquer) partition! ( ) partition! (partition! v x y) v x y 2 (partition! v x y) z

217 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

218 (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

219 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!

220 > (define qweqwe (vector )) #<unspecified> > qweqwe #( ) > (partition! qweqwe 0 11) 4 > qweqwe #( ) partition! , 9, 10, , 4, 3, 3, 1, 0, 2 quick-sort! > (quick-sort! (vector )) #( ) > (quick-sort! (vector )) #( ) make-randam-vector n 8 2 make-random 8 (random number) (pseudo random number)

221 ; 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 ))) (lo (- seed (* hi))) (test (- (* lo) (* hi)))) (if (> test 00) (set! seed test) (set! seed (+ test ))) (/ seed ))) obj) \ ", (, bit, Vol25 No4,, ) 0 1 make-random-vector > (define rand (make-random) #<unspecified> > (make-random-vector 10 rand) #( ) > (make-random-vector 10 rand) #( ) 2 test-sort 1 2 size 3 times 1

222 (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) ( ) 96 Sun SPARC Station ELC ( 24MByte, SunOS 413) SCM 4c4 ( ) n n 0 n, 2 i j i +1 n, 1 i j

223 ( ) b b b b b b b b b b b b b : (10 ) n,2 X n,1 X i=0 j=i+1 1 = n,2 X i=0 (n, i, 1) = n(n, 1)= 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

224 n log 2 n 2 1 n, 1 2 n log 2 n n 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) * 8 n An 2 Bn log 2 n A B 96 A B A B ? 9 9 log 2 n 2 n 2 d = n d = log 2 n

225 Scheme selection-sort! * n n 13 file-sort! (file-sort! inle outle) inle * n log n

226 93 217, \ ",, 1989 S K Park, K W Miller, ( ), \ ", bit, Vol25 No4, pp 19{27,, , Vol25 No7, pp12{20,

227 : k ( h i h i ) S read ADDRESSDAT ( 53 ) ;; DATA FILE FOR ADDRESS BOOK ; NAME PHONE NO (Chisato ) (Narimi ) (Mayuko ) (Misako ) ; end ; read Scheme

228 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

229 *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

230 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))))

231 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) ;;; ;;; addressscm ( FILE VERSION) ;;;

232 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)

233 (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 phone (define (phone name) (let ((phone-number #f)) (open-address-book) (set! phone-number (search-phone name))

234 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)? > (phone 'Mayuko)? > (phone 'Ayako)? "Not found" > (phone 'Misako)? ( ) Scheme

235 ** open-address-book 5 * 6 ** ( FORMAT-1) FORMAT-1 FORMAT-1 7 *** ( ) ( ) 8 **

236 94 2: 227 9

237

238 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

239 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 '( )) 10 > (sum-of-list '(2 3)) 5 > (sum-of-list '()) for-each do for-each for-each > (define (proc s) (display s) (newline)) #<unspecified> > (for-each proc '(a b c)) a b c

240 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))) '( )) v) v ( ) (lambda (n) (set! v (+ v n)) v v 25 for-each h i (side eect) v set! v for-each h i 2 n +

241 Scheme ( ) (let ((v 0)) (for-each (lambda (a b) (set! v (+ v (* a b)))) '( ) '(1 2 3)) v) map map > (map * '(1 2 3) '( )) ( ) (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) '( ) '( )) ( ) > (let ((v 0))

242 101 ( 3) 233 (map (lambda (n) (set! v (+ v n))) '( )) v) aplly (h i h i ) (define (calc op a b) (op a b)) h i op (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)) ( )

243 Scheme ( ) > (apply cons (list 'kanga 'roo)) (kanga roo) > (apply number? (list 2001)) #t > (apply number? (list )) ERROR: apply: Wrong number of args > (apply + (list )) + 15 > (apply (lambda (f1 f2 x) (f1 (f2 x))) (list - sqrt 2)) 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?

244 } (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

245 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 '( )) ( ) > (memv 9 '( )) #f 1023 cons cons alist ((p 314) (e 2718)) ( A h i h i 1021 )

246 alist2 alist () x 10 p 314 e : 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)

247 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

248 (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

249 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 )

250 > `(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, 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

251 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

252 (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))

253 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 ( ) (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 )

254 (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") > ( ) > (resume) BEAR #<unspecified> proc (define (one-day) (display "BREAKFAST") (newline)

255 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>

256 = 3: Scheme 247

257 pppppppp pp pppppppp pppppppp pppppppp pppppppp 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, (tan,1 ) 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)) :

258 tan,1 ( ) =4 = 4 tan,1 ( 1 5 ), tan,1 ( ) = 20 tan,1 ( 1 7 ), 8 tan,1 ( 3 79 ) =4 = 12 tan,1 ( 1 18 )+8tan,1 ( 1 57 ), 5 tan,1 ( ) > (* 4 (- (* 4 (atan (/ 1 5))) (atan (/ 1 239)))) > (+ (* 20 (atan (/ 1 7))) (* 8 (atan (/ 3 79)))) > (* 4 (+ (* 12 (atan (/ 1 18))) (* 8 (atan (/ 1 57))) (- (* 5 (atan (/ 1 239)))))) tan,1 Scheme atan 2 1 ( ) 1

259 tan,1 x = = x x 2 1X n i= x 2 Q i (2m) m=1 Q i (2m +1) ( x 2 m=1 1+x ( x ( 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 x 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)

260 loop P k k, 1 e= 1:010,14 = 0 14 z } { 0: P k +1 k k A k A k+1 = k A k > (atan 01) Scheme e-3 > (arctan 01) e-3 > (arctan 10) > (atan 10) > (- (* 16 (arctan (/ 1 5))) (* 4 (arctan (/ 1 239)))) >(+ (* 20 (arctan (/ 1 7))) (* 8 (arctan (/ 3 79)))) (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, tan, P tan,1 1 5 P tan, P p ;; ;; PI = 16 atan(1/5) - 4 atan(1/239) ;; NOTE: 26 = 5*5 + 1 ;; 956 = 4*239 ;; = 239* e e Scheme

261 (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 (/ )) ; -4atan(1/239) (* (/ ) (/ 2 3)(/ )) 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)) (/ )) (+ k 1)))) ;; PI (loop-16atan1_5 (/ (* 16 5) 26) (* 16 (/ 5 26) (/ 2 3) (/ 1 26)) 1)) > (simple-pi) Scheme d 0 :d 1 d 2 d 3 d 4 d n,1 ( d i 0 9 ) n i d i ( 1 )

262 (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

263 ;;; (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) ; (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 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*

264 *num* *decimal-point* q q q q 113: ( 0: ) *num* 0 (*decimal-point*, 1) *decimal-point* 0: *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, 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,

265 ;; 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, x n,2 = d n,2 I + c n,2 e n,2 = x n,2 mod 10, c n,3 = x n, x n,3 = d n,3 I + c n,3 e n,3 = x n,3 mod 10, c n,4 = x n, I

266 ;; 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, 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))

267 ;; (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) #<unspecified> > (a '/i! 3) #<unspecified> > (a 'show)

268 #<unspecified> > (define b (make-register 50)) #<unspecified> > (b ':=1!) #<unspecified> > (b '/i! 9) b= #<unspecified> > (b '+! b) #<unspecified> > (b 'show) #<unspecified> simple-pi 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

269 K = D log 10 x 2 1+x 2 3 x =1=y K = D log 10 1 y 2 +1 ( y ) 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, n 1 = 707 n 2 = 211 tan, 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 ; = 239* bxc x b4:8c =4,b9c =9 ( floor )

270 (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 (/ )) (Ak ':=1!) ; 4atan(1/239) (Ak '*i! 956) ; Ak (Ak '/i! 57122) ; (PI '-! Ak) ; Ak (956/57122) ; Ak := (* (/ ) (/ 2 3)(/ )) (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)) ; (/ )) (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))

271 ; ; 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! (* )) (Ak '/i! (* )) (loop-16atan1_5 1) ; (PI 'show))) 1000 > (pi 1000) #<unspecified> sin; cos

272 tan,1 2 tan,1 3 pi ** Scheme (bignum) ! = 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! = (Scheme ) 10 * 1000

273 *** 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 ( ), \, ," B-889,, \ ",,

274 ,, \ I,", ,, \ II,", ,, \,",

275 (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

276 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 '( )) (h 1 i h ih 2 i) ERROR: syntax error

277 > (calc-exp0 '(+ 4 10)) ERROR: syntax error (h 1 ih ih 2 i) (calc-exp0 '(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 ( ) Scheme Scheme Scheme "(5 + 8" )

278 j (( + ) BNF (Backus-Naur form) 116 G0 h i h i ( h ih ih i ) h i 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) ) ( ) h 2 i 10 ( G0-3) h i ) h i ( G0-1) ) 4 h i 4 ( G0-3) G0 hi (derivation) calc-exp0 ( ) G0 G0 (4 + 10) 5 1 (4 + 10) 2 h i := ( h ih ih i ) ( G0-1) (4 + 10) ( G0-3 G0-2) 5

279 (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)

280 : ((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)

281 (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) = =

282 = = = = = = : 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 S Min MR AC (Min 0)

283 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 ) ;*

284 (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

285 ((+) (+ 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))) > (calc-exp2 'MR) 7 > (calc-exp2 '(Min (MR + (10-5)))) (10, 5) 12 > (calc-exp2 'MR) ( ) Scheme eq?, car, cdr Scheme C, Fortran, Pascal 1 calc-exp2 * 2 calc-exp2 / 3 * 2 G2 S2

286 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))) e-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

287 , \ ", 4,, 1994 M Hennessy (, ), \," Information&Computing-76,, 1993 J E Hopcroft, J D Ullman (,,, ), \ I," Information&Computing-3,, 1984

288 12 Scheme Scheme Scheme Scheme Scheme Scheme Scheme Scheme Scheme ( ) Scheme Scheme Scheme Scheme TS (Tiny Scheme Scheme) TS (SANS SERIF) TS Scheme (typewriter) TS Scheme 279

289 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)

290 LEN (LENGTH-LOOP (CDR REST) (+ LEN 1))))) (IF (LIST? S) (LENGTH-LOOP S 0) #F))) 1212 Scheme ( 121 ) REP 121: (Read) (Evaluate) (Print) Read-Evaluate-Print REP 2

291 Scheme 3 4 cons, car, + (primitive procedure) 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)

292 (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*

293 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)

294 *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

295 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 ) ( )

296 (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))

297 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))))

298 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) ts:eval 2 exp env exp env

299 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

300 () 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)) F Y (+ Y 2000) 123 new-env

301 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)))

302 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 )

303 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*)))) (LAMBDA )

304 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)

305 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) ))

306 : : : 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

307 Scheme : : : AMOUNT (IF ) MONEY : 100 : : : AMOUNT (IF ) () W1 : W2 : h i MAKE-WALLET : MONEY : : (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)

308 () 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 ( ) ts:reset-environ 129

309 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:

310 env env () () () () X 1 Y 2 Z 3 X 1 Y : 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)

311 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 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)

312 (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))) 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)

313 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)

314 (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

315 Scheme ] (DEFINE N (QUOTE POOH)) N SUM (SUM 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) TS Scheme

316 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

317 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

318 * 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

319 Scheme 13 APPEND 14 LIST-REF 15 SET-CAR! SET-CDR! 16 BOOLEAN? 17 NOT =2 4= 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))))))

320 (SUM 2) N 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

321 Scheme 33 **** Scheme C Pascal Fortran 34 *****

322 Appendix A ASCII ASCII 1 c c E = 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 ( ) * +, - / : ; < = >? 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 ( ) (control character) (control character) 1 ASCII American Standard Code for Information Interchange ` ' ASCII EBCDIC IBM 313

323 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

324 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

325 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 )

326 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)

327 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 :::?

328 } (>= 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

329 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)

330 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)

331 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

332 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 )?

333 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 )

334 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) p (get-universal-time) 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

335 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

336 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

337 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

338 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

339 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

340 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 * ? [ ] [^ ] ^ $ c \c (\or") \ \( \) n \n \`

341 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

342 Appendix D Scheme Scheme Scheme 1 D1 Scheme Scheme ( ) Scheme Scheme compcompliers WWW URL 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

343 334 Appendix D Scheme : FTP ( ) ftp://fptxorgcontrib/elk-22targz MIT Scheme : 72 : Scheme Emacs Scheme : Scheme : 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

344 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 address as password 3 ( ) Password: h i RET FTP ( FTP ) 230-WELCOME TO OUR FTP SERVER!! 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

345 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 May MS-DOS-222 -rw-r--r Nov 1606:19 PATCH rw-r--r Dec ngscm-112targz -rw-r--r Jul ngscm-2231targz -rw-r--r May ngscm-223targz -rw-r--r Nov 1303:37 ngscm326-ng13l+scm4e1targz -rw-r--r Nov 1606:26 ngscm327-ng13l+scm4e1targz -rw-r--r 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 ( bytes) 226 Transfer complete bytes received in 67 seconds (76 Kbytes/s) 8 FTP ftp> quit RET 9 Scheme Steven Allen Robenalt, \Catalog of Free Compilers and Interpreters," /05/04

346 ::::::::::::::::::::::::::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,

347 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

348 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

349 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

350 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 ( ) :::::::::::::::::: :::::::::::::::281 ::::::::::::::::::::::::::::::::248 ::::::::::::::::::::::::::55,56,142 :::::::::::::::::::::::::::::::::::::286 ::::::::::::::::::::::::::::::::::::211

351 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

352 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

353 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

354 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

355 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

356 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

357 348 X #x ::::::::::::::::::::::::::::::::::::::127 Y yank ::::::::::::::::::::::::::::::::::::162 Z zero? :::::::::::::::::::::::::::::::43,319

X Window System X X &

X Window System X X & 1 1 1.1 X Window System................................... 1 1.2 X......................................... 1 1.3 X &................................ 1 1.3.1 X.......................... 1 1.3.2 &....................................

More information

GNU Emacs GNU Emacs

GNU Emacs GNU Emacs GNU Emacs 2015 10 2 1 GNU Emacs 1 1.1....................................... 1 1.2....................................... 1 1.2.1..................................... 1 1.2.2.....................................

More information

1. A0 A B A0 A : A1,...,A5 B : B1,...,B

1. A0 A B A0 A : A1,...,A5 B : B1,...,B 1. A0 A B A0 A : A1,...,A5 B : B1,...,B12 2. 3. 4. 5. A0 A, B Z Z m, n Z m n m, n A m, n B m=n (1) A, B (2) A B = A B = Z/ π : Z Z/ (3) A B Z/ (4) Z/ A, B (5) f : Z Z f(n) = n f = g π g : Z/ Z A, B (6)

More information

つくって学ぶプログラミング言語 RubyによるScheme処理系の実装

つくって学ぶプログラミング言語 RubyによるScheme処理系の実装 Ruby Scheme 2013-04-16 ( )! SICP *1 ;-) SchemeR SICP MIT * 1 Structure and Interpretaion of Computer Programs 2nd ed.: 2 i SchemeR Ruby Ruby Ruby Ruby & 3.0 Ruby ii https://github.com/ichusrlocalbin/scheme_in_ruby

More information

1. A0 A B A0 A : A1,...,A5 B : B1,...,B12 2. 5 3. 4. 5. A0 (1) A, B A B f K K A ϕ 1, ϕ 2 f ϕ 1 = f ϕ 2 ϕ 1 = ϕ 2 (2) N A 1, A 2, A 3,... N A n X N n X N, A n N n=1 1 A1 d (d 2) A (, k A k = O), A O. f

More information

n 第1章 章立ての部分は、書式(PC入門大見出し)を使います

n 第1章 章立ての部分は、書式(PC入門大見出し)を使います FORTRAN FORTRAN FORTRAN ) DO DO IF IF FORTRAN FORTRAN(FORmula TRANslator)1956 IBM FORTRAN IV FORTRAN77 Fortran90 FORTRAN77 FORTRAN FORTARN IF, DO C UNIX FORTRAN PASCAL COBOL PL/I BASIC Lisp PROLOG Lisp

More information

r3.dvi

r3.dvi 2012 3 / Lisp(2) 2012.4.19 1 Lisp 1.1 Lisp Lisp (1) (setq) (2) (3) setq defun (defun (... &aux...)...) ( ) ( nil ) [1]> (defun sisoku (x y &aux wa sa sho seki) (setq wa (+ x y)) (setq sa (- x y)) (setq

More information

Fortran90/95 [9]! (1 ) " " 5 "Hello!"! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1

Fortran90/95 [9]! (1 )   5 Hello!! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1 Fortran90/95 2.1 Fortran 2-1 Hello! 1 program example2_01! end program 2! first test program ( ) 3 implicit none! 4 5 write(*,*) "Hello!"! write Hello! 6 7 stop! 8 end program example2_01 1 program 1!

More information

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for embedded systems that use microcontrollers (MCUs)

More information

0 (18) /12/13 (19) n Z (n Z ) 5 30 (5 30 ) (mod 5) (20) ( ) (12, 8) = 4

0   (18) /12/13 (19) n Z (n Z ) 5 30 (5 30 ) (mod 5) (20) ( ) (12, 8) = 4 0 http://homepage3.nifty.com/yakuikei (18) 1 99 3 2014/12/13 (19) 1 100 3 n Z (n Z ) 5 30 (5 30 ) 37 22 (mod 5) (20) 201 300 3 (37 22 5 ) (12, 8) = 4 (21) 16! 2 (12 8 4) (22) (3 n )! 3 (23) 100! 0 1 (1)

More information

2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa

2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa I 2017 11 1 SageMath SageMath( Sage ) Sage Python Sage Python Sage Maxima Maxima Sage Sage Sage Linux, Mac, Windows *1 2 Sage Sage 4 1. ( sage CUI) 2. Sage ( sage.sage ) 3. Sage ( notebook() ) 4. Sage

More information

Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS Pascal

Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS Pascal Pascal Pascal Pascal Free Pascal CPad for Pascal Microsoft Windows OS 2010 10 1 Pascal 2 1.1.......................... 2 1.2.................. 2 1.3........................ 3 2 4 2.1................................

More information

Microsoft PowerPoint - IntroAlgDs-05-2.ppt

Microsoft PowerPoint - IntroAlgDs-05-2.ppt アルゴリズムとデータ構造入門 2005 年 10 月 11 日 アルゴリズムとデータ構造入門 1. 手続きによる抽象の構築 1.1 プログラムの要素 奥乃 博 1. TUT Schemeが公開されました. Windowsは動きます. Linux, Cygwin はうまく行かず. 調査中. 2. 随意課題 7の追加 友人の勉学を助け,TAの手伝いをする. 支援した内容を毎回のレポート等で詳細に報告.

More information

Microsoft PowerPoint - IntroAlgDs pptx

Microsoft PowerPoint - IntroAlgDs pptx アルゴリズムとデータ構造入門 -11 2013 年 12 月 17 日 大学院情報学研究科知能情報学専攻 http://winnie.kuis.kyotou.ac.jp/~okuno/lecture/13/introalgds/ [email protected] if mod( 学籍番号の下 3 桁,3) 0 if mod( 学籍番号の下 3 桁,3) 1 if mod( 学籍番号の下 3

More information

25 II :30 16:00 (1),. Do not open this problem booklet until the start of the examination is announced. (2) 3.. Answer the following 3 proble

25 II :30 16:00 (1),. Do not open this problem booklet until the start of the examination is announced. (2) 3.. Answer the following 3 proble 25 II 25 2 6 13:30 16:00 (1),. Do not open this problem boolet until the start of the examination is announced. (2) 3.. Answer the following 3 problems. Use the designated answer sheet for each problem.

More information

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1 I117 II I117 PROGRAMMING PRACTICE II 2 MEMORY MANAGEMENT 2 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara [email protected] / SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming

More information

,,,,., C Java,,.,,.,., ,,.,, i

,,,,., C Java,,.,,.,., ,,.,, i 24 Development of the programming s learning tool for children be derived from maze 1130353 2013 3 1 ,,,,., C Java,,.,,.,., 1 6 1 2.,,.,, i Abstract Development of the programming s learning tool for children

More information

program.dvi

program.dvi 2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation

More information

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC PBASIC 2.5 PBASIC 2.5 BASIC Stamp Editor / Development System Version 2.0 Beta Release 2 2.0 PBASIC BASIC StampR PBASIC PBASIC PBASIC 2.5 Parallax, Inc. PBASIC 2.5 PBASIC 2.5 [email protected] 1

More information

13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software Nspire Nspire Nspir

13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software Nspire Nspire Nspir 13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software 37.1 37.1 Nspire Nspire Nspire 37.1: Student Software 13 2 13 Student Software esc

More information

1 1.1 (JCPRG) 30 Nuclear Reaction Data File (NRDF) PC GSYS2.4 JCPRG GSYS2.4 Java Windows, Linux, Max OS X, FreeBSD GUI PNG, GIF, JPEG X Y GSYS2

1 1.1 (JCPRG) 30 Nuclear Reaction Data File (NRDF) PC GSYS2.4 JCPRG GSYS2.4 Java Windows, Linux, Max OS X, FreeBSD GUI PNG, GIF, JPEG X Y GSYS2 (GSYS2.4) GSYS2.4 Manual SUZUKI Ryusuke Hokkaido University Hospital Abstract GSYS2.4 is an update version of GSYS version 2. Main features added in this version are Magnifying glass function, Automatically

More information

たのしいプログラミング Pythonではじめよう!

たのしいプログラミング Pythonではじめよう! Title of English-language original: Python for Kids A Playful Introduction to Programming ISBN 978-1-59327-407-8, published by No Starch Press, Inc. Copyright 2013 by Jason R. Briggs. Japanese-language

More information

スパコンに通じる並列プログラミングの基礎

スパコンに通じる並列プログラミングの基礎 2016.06.06 2016.06.06 1 / 60 2016.06.06 2 / 60 Windows, Mac Unix 0444-J 2016.06.06 3 / 60 Part I Unix GUI CUI: Unix, Windows, Mac OS Part II 0444-J 2016.06.06 4 / 60 ( : ) 6 6 ( ) 6 10 6 16 SX-ACE 6 17

More information

fx-9860G Manager PLUS_J

fx-9860G Manager PLUS_J fx-9860g J fx-9860g Manager PLUS http://edu.casio.jp k 1 k III 2 3 1. 2. 4 3. 4. 5 1. 2. 3. 4. 5. 1. 6 7 k 8 k 9 k 10 k 11 k k k 12 k k k 1 2 3 4 5 6 1 2 3 4 5 6 13 k 1 2 3 1 2 3 1 2 3 1 2 3 14 k a j.+-(),m1

More information

グラフ数値読み取りシステム (GSYS2.4) 利用の手引

グラフ数値読み取りシステム (GSYS2.4) 利用の手引 (GSYS2.4) GSYS2.4 Manual SUZUKI Ryusuke Hokkaido University Hospital 2011 6 7 Abstract GSYS2.4 is an update version of GSYS version 2. Main features added in this version are Magnifying glass function,

More information

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè11²ó

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè11²ó 11 2013 6 19 11 (6/19) 6 (18:10-19:40) λ13 UNIX : 2 / 26 UNIX UNIX sort, head, tail, cat, cut diff, tee, grep, uniq, wc join, find, sed, awk, screen 3 / 26 sort sort : $ sort [options] [FILE...] options

More information

syspro-0405.ppt

syspro-0405.ppt 3 4, 5 1 UNIX csh 2.1 bash X Window 2 grep l POSIX * more POSIX 3 UNIX. 4 first.sh #!bin/sh #first.sh #This file looks through all the files in the current #directory for the string yamada, and then prints

More information

コンピュータ概論

コンピュータ概論 4.1 For Check Point 1. For 2. 4.1.1 For (For) For = To Step (Next) 4.1.1 Next 4.1.1 4.1.2 1 i 10 For Next Cells(i,1) Cells(1, 1) Cells(2, 1) Cells(10, 1) 4.1.2 50 1. 2 1 10 3. 0 360 10 sin() 4.1.2 For

More information

学習内容と日常生活との関連性の研究-第2部-第4章-1

学習内容と日常生活との関連性の研究-第2部-第4章-1 69 V A V + A V A 2A 2 http://www.jba-hp.jp/ http://www.kbn3.com/ http://www.usba.org/ 70 (1) (1996)35 7 pp.28-33 (2) (1994) 71 () 3 1 1 99 8 1 10 1 11.3 2.5 1 100 11.4 30.9 1 72 (1) http://www.stat.go.jp/data/zensho/1999/zuhyou/a906-6.xls

More information

Microsoft PowerPoint - IntroAlgDs-05-4.ppt

Microsoft PowerPoint - IntroAlgDs-05-4.ppt アルゴリズムとデータ構造入門 2005 年 0 月 25 日 アルゴリズムとデータ構造入門. 手続きによる抽象の構築.2 Procedures and the Processes They generate ( 手続きとそれが生成するプロセス ) 奥乃 博. TUT Scheme が公開されました. Windows は動きます. Linux, Cygwin も動きます. 0 月 25 日 本日のメニュー.2.

More information

2017 (413812)

2017 (413812) 2017 (413812) Deep Learning ( NN) 2012 Google ASIC(Application Specific Integrated Circuit: IC) 10 ASIC Deep Learning TPU(Tensor Processing Unit) NN 12 20 30 Abstract Multi-layered neural network(nn) has

More information

I117 II I117 PROGRAMMING PRACTICE II SOFTWARE DEVELOPMENT ENV. 1 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara

I117 II I117 PROGRAMMING PRACTICE II SOFTWARE DEVELOPMENT ENV. 1 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara I117 II I117 PROGRAMMING PRACTICE II SOFTWARE DEVELOPMENT ENV. 1 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara [email protected] / SCHEDULE 1. 2011/06/07(Tue) / Basic of

More information

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf (%s, str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i ABC066 / ARC077 writer: nuip 2017 7 1 For International Readers: English editorial starts from page 8. A : ringring a + b b + c a + c a, b, c a + b + c 1 # include < stdio.h> 2 3 int main (){ 4 int a,

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu II 4 : 2001 11 7 keywords: 1 OCaml OCaml (first-class value) (higher-order function) 1.1 1 2 + 2 2 + + n 2 sqsum 1 3 + 2 3 + + n 3 cbsum # let rec sqsum n = # if n = 0 then 0 else n * n + sqsum (n - 1)

More information

C FGIH C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C

C FGIH C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C TUDSR5SET TUDSR5 C 7 8 9 ch DIGITAL CS TUNER C C C C S-A C FGIH C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C

More information

GPGPU

GPGPU GPGPU 2013 1008 2015 1 23 Abstract In recent years, with the advance of microscope technology, the alive cells have been able to observe. On the other hand, from the standpoint of image processing, the

More information

# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n

# let st1 = {name = Taro Yamada; id = };; val st1 : student = {name=taro Yamada; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n II 6 / : 2001 11 21 (OCaml ) 1 (field) name id type # type student = {name : string; id : int};; type student = { name : string; id : int; } student {} type = { 1 : 1 ;...; n : n } { 1 = 1 ;...; n = n

More information

Microsoft Word - D JP.docx

Microsoft Word - D JP.docx Application Service Gateway Thunder/AX Series vthunder ライセンスキー インストール 手順 1 1.... 3 2. vthunder... 3 3. ACOS... 3 4. ID... 5 5.... 8 6.... 8 61... 8 62 GUI... 10 2 1. 概要 2. vthunder へのアクセス 方法 SSHHTTPSvThunder

More information

Nios® II HAL API を使用したソフトウェア・サンプル集 「Modular Scatter-Gather DMA Core」

Nios® II HAL API を使用したソフトウェア・サンプル集 「Modular Scatter-Gather DMA Core」 ALTIMA Company, MACNICA, Inc Nios II HAL API Modular Scatter-Gather DMA Core Ver.17.1 2018 8 Rev.1 Nios II HAL API Modular Scatter-Gather DMA Core...3...3...4... 4... 5 3-2-1. msgdma... 6 3-2-2. On-Chip

More information

2

2 L C -24K 9 L C -22K 9 2 3 4 5 6 7 8 9 10 11 12 11 03 AM 04 05 0 PM 1 06 1 PM 07 00 00 08 2 PM 00 4 PM 011 011 021 041 061 081 051 071 1 2 4 6 8 5 7 00 00 00 00 00 00 00 00 30 00 09 00 15 10 3 PM 45 00

More information

スパコンに通じる並列プログラミングの基礎

スパコンに通じる並列プログラミングの基礎 2018.06.04 2018.06.04 1 / 62 2018.06.04 2 / 62 Windows, Mac Unix 0444-J 2018.06.04 3 / 62 Part I Unix GUI CUI: Unix, Windows, Mac OS Part II 2018.06.04 4 / 62 0444-J ( : ) 6 4 ( ) 6 5 * 6 19 SX-ACE * 6

More information

1 1 Gnuplot gnuplot Windows gnuplot gp443win32.zip gnuplot binary, contrib, demo, docs, license 5 BUGS, Chang

1 1 Gnuplot gnuplot   Windows gnuplot gp443win32.zip gnuplot binary, contrib, demo, docs, license 5 BUGS, Chang Gnuplot で微分積分 2011 年度前期 数学解析 I 講義資料 (2011.6.24) 矢崎成俊 ( 宮崎大学 ) 1 1 Gnuplot gnuplot http://www.gnuplot.info/ Windows gnuplot 2011 6 22 4.4.3 gp443win32.zip gnuplot binary, contrib, demo, docs, license 5

More information

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV [email protected] [email protected] http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/sem3/ 2002 11 20 p.1/34 10/16 1. 10/23 2. 10/30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20

More information

,, create table drop table alter table

,, create table drop table alter table PostgreSQL 1 1 2 1 3,, 2 3.1 - create table........................... 2 3.2 - drop table............................ 3 3.3 - alter table............................ 4 4 - copy 5 4.1..................................

More information

Specview Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page htt

Specview Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page   htt Specview Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page http://www.stsci.edu/resources/software_hardware/specview http://specview.stsci.edu/javahelp/main.html Specview

More information

Solution Report

Solution Report CGE 3 GAMS * Date: 2018/07/24, Version 1.1 1 2 2 GAMSIDE 3 2.1 GAMS................................. 3 2.2 GAMSIDE................................ 3 2.3 GAMSIDE............................. 7 3 GAMS 11

More information

listings-ext

listings-ext (6) Python (2) ( ) [email protected] 5 Python (2) 1 5.1 (statement)........................... 1 5.2 (scope)......................... 11 5.3 (subroutine).................... 14 5 Python (2) Python 5.1

More information

RT300/140/105シリーズ 取扱説明書

RT300/140/105シリーズ 取扱説明書 REMOTE & BROADBAND ROUTER RT300i/RT140p/RT140f/RT140i RT140e/RT105p/RT105i/RT105e 2 3 4 5 6 7 8 9 10 Bold face Enter Ctrl Tab BS Del Console RT105i RT300i RT140p RT140f RT140i RT140e RT105p RT105i RT105e

More information

28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment

28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment 28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment 1170288 2017 2 28 Docker,.,,.,,.,,.,. Docker.,..,., Web, Web.,.,.,, CPU,,. i ., OS..,, OS, VirtualBox,.,

More information

Microsoft Word - Win-Outlook.docx

Microsoft Word - Win-Outlook.docx Microsoft Office Outlook での設定方法 (IMAP および POP 編 ) How to set up with Microsoft Office Outlook (IMAP and POP) 0. 事前に https://office365.iii.kyushu-u.ac.jp/login からサインインし 以下の手順で自分の基本アドレスをメモしておいてください Sign

More information

ストラドプロシージャの呼び出し方

ストラドプロシージャの呼び出し方 Release10.5 Oracle DataServer Informix MS SQL NXJ SQL JDBC Java JDBC NXJ : NXJ JDBC / NXJ EXEC SQL [USING CONNECTION ] CALL [.][.] ([])

More information

haskell.gby

haskell.gby Haskell 1 2 3 Haskell ( ) 4 Haskell Lisper 5 Haskell = Haskell 6 Haskell Haskell... 7 qsort [8,2,5,1] [1,2,5,8] "Hello, " ++ "world!" "Hello, world!" 1 + 2 div 8 2 (+) 1 2 8 div 2 3 4 map even [1,2,3,4]

More information

1,.,,,., RDBM, SQL. OSS,, SQL,,.

1,.,,,., RDBM, SQL. OSS,, SQL,,. 1,.,,,., RDBM, SQL. OSS,, SQL,,. 3 10 10 OSS RDBMS SQL 11 10.1 OSS RDBMS............................ 11 10.1.1 PostgreSQL................................. 11 10.1.2 MySQL...................................

More information

1 138

1 138 5 1 2 3 4 5 6 7 8 1 138 BIOS Setup Utility MainAdvancedSecurityPowerExit Setup Warning Item Specific Help Setting items on this menu to incorrect values may cause your system to malfunction. Select 'Yes'

More information

01_OpenMP_osx.indd

01_OpenMP_osx.indd OpenMP* / 1 1... 2 2... 3 3... 5 4... 7 5... 9 5.1... 9 5.2 OpenMP* API... 13 6... 17 7... 19 / 4 1 2 C/C++ OpenMP* 3 Fortran OpenMP* 4 PC 1 1 9.0 Linux* Windows* Xeon Itanium OS 1 2 2 WEB OS OS OS 1 OS

More information

Jacques Garrigue

Jacques Garrigue Jacques Garrigue Garrigue 1 Garrigue 2 $ print_lines () > for i in $1; do > echo $i > done $ print_lines "a b c" a b c Garrigue 3 Emacs Lisp (defun print-lines (lines) (dolist (str lines) (insert str)

More information

LC304_manual.ai

LC304_manual.ai Stick Type Electronic Calculator English INDEX Stick Type Electronic Calculator Instruction manual INDEX Disposal of Old Electrical & Electronic Equipment (Applicable in the European Union

More information

スパコンに通じる並列プログラミングの基礎

スパコンに通じる並列プログラミングの基礎 2018.09.10 [email protected] ( ) 2018.09.10 1 / 59 [email protected] ( ) 2018.09.10 2 / 59 Windows, Mac Unix 0444-J [email protected] ( ) 2018.09.10 3 / 59 Part I Unix GUI CUI:

More information

num2.dvi

num2.dvi [email protected] http://kanenko.a.la9.jp/ 16 32...... h 0 h = ε () 0 ( ) 0 1 IEEE754 (ieee754.c Kerosoft Ltd.!) 1 2 : OS! : WindowsXP ( ) : X Window xcalc.. (,.) C double 10,??? 3 :, ( ) : BASIC,

More information

pptx

pptx iphone 2010 8 18 C [email protected] C Hello, World! Hello World hello.c! printf( Hello, World!\n );! os> ls! hello.c! os> cc hello.c o hello! os> ls! hello!!hello.c! os>./hello! Hello, World!! os>! os>

More information

( ) [2] H 4 4! H 4 4! (5 4 3 )= = Fortran C 0 #include <stdio.h> 1 #include

( ) [2] H 4 4! H 4 4! (5 4 3 )= = Fortran C 0 #include <stdio.h> 1 #include J.JSSAC (2006) Vol. 12, No. 3, pp. 3-16 IIJ 2000 8 bit TULIPS KING KISS WINK 1 ( ) Ackermann GC [1] CPU 6502 [email protected] c 2006 Japan Society for Symbolic and Algebraic Computation 4 12 3 2006 (1943-05-16

More information

r08.dvi

r08.dvi 19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev

More information

エッセー

エッセー 5.13................................... 3 5.14........................................ 9 5.15.................................. 12 5.16................................ 15 5.17..................... 18 5.18...................................

More information