Artifact
e26b7f0552d554a4aa2e6fc39bd817137ed016e0:
- File
fmt/test-fmt.scm
— part of check-in
[80c8c83034]
at
2016-07-07 18:11:39
on branch trunk
— initial import
(user:
ovenpasta@pizzahack.eu
size: 18870)
0000: 0a 28 63 6f 6e 64 2d 65 78 70 61 6e 64 0a 20 28 .(cond-expand. (
0010: 63 68 69 63 6b 65 6e 0a 20 20 28 6c 6f 61 64 20 chicken. (load
0020: 22 66 6d 74 2d 63 68 69 63 6b 65 6e 2e 73 63 6d "fmt-chicken.scm
0030: 22 29 29 0a 20 28 65 6c 73 65 29 29 0a 0a 28 63 ")). (else))..(c
0040: 6f 6e 64 2d 65 78 70 61 6e 64 0a 20 28 63 68 69 ond-expand. (chi
0050: 63 6b 65 6e 0a 20 20 28 75 73 65 20 74 65 73 74 cken. (use test
0060: 29 0a 20 20 28 69 6d 70 6f 72 74 20 66 6d 74 29 ). (import fmt)
0070: 29 0a 20 28 67 61 75 63 68 65 0a 20 20 28 75 73 ). (gauche. (us
0080: 65 20 67 61 75 63 68 65 2e 74 65 73 74 29 0a 20 e gauche.test).
0090: 20 28 75 73 65 20 74 65 78 74 2e 66 6d 74 29 0a (use text.fmt).
00a0: 20 20 28 64 65 66 69 6e 65 20 74 65 73 74 2d 62 (define test-b
00b0: 65 67 69 6e 20 74 65 73 74 2d 73 74 61 72 74 29 egin test-start)
00c0: 0a 20 20 28 64 65 66 69 6e 65 20 6f 72 69 67 2d . (define orig-
00d0: 74 65 73 74 20 28 77 69 74 68 2d 6d 6f 64 75 6c test (with-modul
00e0: 65 20 67 61 75 63 68 65 2e 74 65 73 74 20 74 65 e gauche.test te
00f0: 73 74 29 29 0a 20 20 28 64 65 66 69 6e 65 2d 73 st)). (define-s
0100: 79 6e 74 61 78 20 74 65 73 74 0a 20 20 20 20 28 yntax test. (
0110: 73 79 6e 74 61 78 2d 72 75 6c 65 73 20 28 29 0a syntax-rules ().
0120: 20 20 20 20 20 20 28 28 74 65 73 74 20 6e 61 6d ((test nam
0130: 65 20 65 78 70 65 63 74 65 64 20 65 78 70 72 29 e expected expr)
0140: 0a 20 20 20 20 20 20 20 28 67 75 61 72 64 20 28 . (guard (
0150: 65 20 28 65 6c 73 65 20 23 66 29 29 0a 20 20 20 e (else #f)).
0160: 20 20 20 20 20 20 20 20 20 20 20 28 6f 72 69 67 (orig
0170: 2d 74 65 73 74 20 6e 61 6d 65 20 65 78 70 65 63 -test name expec
0180: 74 65 64 20 28 6c 61 6d 62 64 61 20 28 29 20 65 ted (lambda () e
0190: 78 70 72 29 29 29 29 0a 20 20 20 20 20 20 28 28 xpr)))). ((
01a0: 74 65 73 74 20 65 78 70 65 63 74 65 64 20 65 78 test expected ex
01b0: 70 72 29 0a 20 20 20 20 20 20 20 28 74 65 73 74 pr). (test
01c0: 20 28 6c 65 74 20 28 28 73 20 28 77 69 74 68 2d (let ((s (with-
01d0: 6f 75 74 70 75 74 2d 74 6f 2d 73 74 72 69 6e 67 output-to-string
01e0: 20 28 6c 61 6d 62 64 61 20 28 29 20 28 77 72 69 (lambda () (wri
01f0: 74 65 20 27 65 78 70 72 29 29 29 29 29 0a 20 20 te 'expr))))).
0200: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 73 75 (su
0210: 62 73 74 72 69 6e 67 20 73 20 30 20 28 6d 69 6e bstring s 0 (min
0220: 20 36 30 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 60 (string-leng
0230: 74 68 20 73 29 29 29 29 0a 20 20 20 20 20 20 20 th s)))).
0240: 20 20 20 20 20 20 65 78 70 65 63 74 65 64 20 65 expected e
0250: 78 70 72 29 29 29 29 29 0a 20 28 65 6c 73 65 29 xpr))))). (else)
0260: 29 0a 0a 28 74 65 73 74 2d 62 65 67 69 6e 20 22 )..(test-begin "
0270: 66 6d 74 22 29 0a 0a 3b 3b 20 62 61 73 69 63 20 fmt")..;; basic
0280: 64 61 74 61 20 74 79 70 65 73 0a 0a 28 74 65 73 data types..(tes
0290: 74 20 22 68 69 22 20 28 66 6d 74 20 23 66 20 22 t "hi" (fmt #f "
02a0: 68 69 22 29 29 0a 28 74 65 73 74 20 22 5c 22 68 hi")).(test "\"h
02b0: 69 5c 22 22 20 28 66 6d 74 20 23 66 20 28 77 72 i\"" (fmt #f (wr
02c0: 74 20 22 68 69 22 29 29 29 0a 28 74 65 73 74 20 t "hi"))).(test
02d0: 22 5c 22 68 69 20 5c 5c 5c 22 62 6f 62 5c 5c 5c "\"hi \\\"bob\\\
02e0: 22 5c 22 22 20 28 66 6d 74 20 23 66 20 28 77 72 "\"" (fmt #f (wr
02f0: 74 20 22 68 69 20 5c 22 62 6f 62 5c 22 22 29 29 t "hi \"bob\""))
0300: 29 0a 28 74 65 73 74 20 22 5c 22 68 65 6c 6c 6f ).(test "\"hello
0310: 5c 5c 6e 77 6f 72 6c 64 5c 22 22 20 28 66 6d 74 \\nworld\"" (fmt
0320: 20 23 66 20 28 77 72 74 20 22 68 65 6c 6c 6f 5c #f (wrt "hello\
0330: 6e 77 6f 72 6c 64 22 29 29 29 0a 28 74 65 73 74 nworld"))).(test
0340: 20 22 41 42 43 22 20 28 66 6d 74 20 23 66 20 28 "ABC" (fmt #f (
0350: 75 70 63 61 73 65 20 22 61 62 63 22 29 29 29 0a upcase "abc"))).
0360: 28 74 65 73 74 20 22 61 62 63 22 20 28 66 6d 74 (test "abc" (fmt
0370: 20 23 66 20 28 64 6f 77 6e 63 61 73 65 20 22 41 #f (downcase "A
0380: 42 43 22 29 29 29 0a 28 74 65 73 74 20 22 41 62 BC"))).(test "Ab
0390: 63 22 20 28 66 6d 74 20 23 66 20 28 74 69 74 6c c" (fmt #f (titl
03a0: 65 63 61 73 65 20 22 61 62 63 22 29 29 29 0a 0a ecase "abc")))..
03b0: 28 74 65 73 74 20 22 61 62 63 20 20 20 20 20 64 (test "abc d
03c0: 65 66 22 20 28 66 6d 74 20 23 66 20 22 61 62 63 ef" (fmt #f "abc
03d0: 22 20 28 74 61 62 2d 74 6f 29 20 22 64 65 66 22 " (tab-to) "def"
03e0: 29 29 0a 28 74 65 73 74 20 22 61 62 63 20 20 64 )).(test "abc d
03f0: 65 66 22 20 28 66 6d 74 20 23 66 20 22 61 62 63 ef" (fmt #f "abc
0400: 22 20 28 74 61 62 2d 74 6f 20 35 29 20 22 64 65 " (tab-to 5) "de
0410: 66 22 29 29 0a 28 74 65 73 74 20 22 61 62 63 64 f")).(test "abcd
0420: 65 66 22 20 28 66 6d 74 20 23 66 20 22 61 62 63 ef" (fmt #f "abc
0430: 22 20 28 74 61 62 2d 74 6f 20 33 29 20 22 64 65 " (tab-to 3) "de
0440: 66 22 29 29 0a 0a 28 74 65 73 74 20 22 2d 31 22 f"))..(test "-1"
0450: 20 28 66 6d 74 20 23 66 20 2d 31 29 29 0a 28 74 (fmt #f -1)).(t
0460: 65 73 74 20 22 30 22 20 28 66 6d 74 20 23 66 20 est "0" (fmt #f
0470: 30 29 29 0a 28 74 65 73 74 20 22 31 22 20 28 66 0)).(test "1" (f
0480: 6d 74 20 23 66 20 31 29 29 0a 28 74 65 73 74 20 mt #f 1)).(test
0490: 22 31 30 22 20 28 66 6d 74 20 23 66 20 31 30 29 "10" (fmt #f 10)
04a0: 29 0a 28 74 65 73 74 20 22 31 30 30 22 20 28 66 ).(test "100" (f
04b0: 6d 74 20 23 66 20 31 30 30 29 29 0a 28 74 65 73 mt #f 100)).(tes
04c0: 74 20 22 2d 31 22 20 28 66 6d 74 20 23 66 20 28 t "-1" (fmt #f (
04d0: 6e 75 6d 20 2d 31 29 29 29 0a 28 74 65 73 74 20 num -1))).(test
04e0: 22 30 22 20 28 66 6d 74 20 23 66 20 28 6e 75 6d "0" (fmt #f (num
04f0: 20 30 29 29 29 0a 28 74 65 73 74 20 22 31 22 20 0))).(test "1"
0500: 28 66 6d 74 20 23 66 20 28 6e 75 6d 20 31 29 29 (fmt #f (num 1))
0510: 29 0a 28 74 65 73 74 20 22 31 30 22 20 28 66 6d ).(test "10" (fm
0520: 74 20 23 66 20 28 6e 75 6d 20 31 30 29 29 29 0a t #f (num 10))).
0530: 28 74 65 73 74 20 22 31 30 30 22 20 28 66 6d 74 (test "100" (fmt
0540: 20 23 66 20 28 6e 75 6d 20 31 30 30 29 29 29 0a #f (num 100))).
0550: 3b 3b 20 28 74 65 73 74 20 22 31 65 2b 31 35 22 ;; (test "1e+15"
0560: 20 28 66 6d 74 20 23 66 20 28 6e 75 6d 20 31 65 (fmt #f (num 1e
0570: 2b 31 35 29 29 29 0a 3b 3b 20 28 74 65 73 74 20 +15))).;; (test
0580: 22 31 65 2b 32 33 22 20 28 66 6d 74 20 23 66 20 "1e+23" (fmt #f
0590: 28 6e 75 6d 20 31 65 2b 32 33 29 29 29 0a 3b 3b (num 1e+23))).;;
05a0: 20 28 74 65 73 74 20 22 31 2e 32 65 2b 32 33 22 (test "1.2e+23"
05b0: 20 28 66 6d 74 20 23 66 20 28 6e 75 6d 20 31 2e (fmt #f (num 1.
05c0: 32 65 2b 32 33 29 29 29 0a 3b 3b 20 28 74 65 73 2e+23))).;; (tes
05d0: 74 20 22 31 65 2d 35 22 20 28 66 6d 74 20 23 66 t "1e-5" (fmt #f
05e0: 20 28 6e 75 6d 20 31 65 2d 35 29 29 29 0a 3b 3b (num 1e-5))).;;
05f0: 20 28 74 65 73 74 20 22 31 65 2d 36 22 20 28 66 (test "1e-6" (f
0600: 6d 74 20 23 66 20 28 6e 75 6d 20 31 65 2d 36 29 mt #f (num 1e-6)
0610: 29 29 0a 3b 3b 20 28 74 65 73 74 20 22 31 65 2d )).;; (test "1e-
0620: 37 22 20 28 66 6d 74 20 23 66 20 28 6e 75 6d 20 7" (fmt #f (num
0630: 31 65 2d 37 29 29 29 0a 3b 3b 20 28 74 65 73 74 1e-7))).;; (test
0640: 20 22 32 65 2d 36 22 20 28 66 6d 74 20 23 66 20 "2e-6" (fmt #f
0650: 28 6e 75 6d 20 32 65 2d 36 29 29 29 0a 28 74 65 (num 2e-6))).(te
0660: 73 74 20 22 35 37 30 30 35 22 20 28 66 6d 74 20 st "57005" (fmt
0670: 23 66 20 23 78 44 45 41 44 29 29 0a 28 74 65 73 #f #xDEAD)).(tes
0680: 74 20 22 23 78 44 45 41 44 22 20 28 66 6d 74 20 t "#xDEAD" (fmt
0690: 23 66 20 28 72 61 64 69 78 20 31 36 20 23 78 44 #f (radix 16 #xD
06a0: 45 41 44 29 29 29 0a 28 74 65 73 74 20 22 23 78 EAD))).(test "#x
06b0: 44 45 41 44 31 32 33 34 22 20 28 66 6d 74 20 23 DEAD1234" (fmt #
06c0: 66 20 28 72 61 64 69 78 20 31 36 20 23 78 44 45 f (radix 16 #xDE
06d0: 41 44 29 20 31 32 33 34 29 29 0a 28 74 65 73 74 AD) 1234)).(test
06e0: 20 22 23 78 44 45 2e 41 44 22 20 28 66 6d 74 20 "#xDE.AD" (fmt
06f0: 23 66 20 28 72 61 64 69 78 20 31 36 20 28 65 78 #f (radix 16 (ex
0700: 61 63 74 2d 3e 69 6e 65 78 61 63 74 20 28 2f 20 act->inexact (/
0710: 23 78 44 45 41 44 20 23 78 31 30 30 29 29 29 29 #xDEAD #x100))))
0720: 29 0a 28 74 65 73 74 20 22 23 78 44 2e 45 41 44 ).(test "#xD.EAD
0730: 22 20 28 66 6d 74 20 23 66 20 28 72 61 64 69 78 " (fmt #f (radix
0740: 20 31 36 20 28 65 78 61 63 74 2d 3e 69 6e 65 78 16 (exact->inex
0750: 61 63 74 20 28 2f 20 23 78 44 45 41 44 20 23 78 act (/ #xDEAD #x
0760: 31 30 30 30 29 29 29 29 29 0a 28 74 65 73 74 20 1000))))).(test
0770: 22 23 78 30 2e 44 45 41 44 22 20 28 66 6d 74 20 "#x0.DEAD" (fmt
0780: 23 66 20 28 72 61 64 69 78 20 31 36 20 28 65 78 #f (radix 16 (ex
0790: 61 63 74 2d 3e 69 6e 65 78 61 63 74 20 28 2f 20 act->inexact (/
07a0: 23 78 44 45 41 44 20 23 78 31 30 30 30 30 29 29 #xDEAD #x10000))
07b0: 29 29 29 0a 28 74 65 73 74 20 22 31 47 22 20 28 ))).(test "1G" (
07c0: 66 6d 74 20 23 66 20 28 72 61 64 69 78 20 31 37 fmt #f (radix 17
07d0: 20 28 6e 75 6d 20 33 33 29 29 29 29 0a 28 74 65 (num 33)))).(te
07e0: 73 74 20 22 31 47 22 20 28 66 6d 74 20 23 66 20 st "1G" (fmt #f
07f0: 28 6e 75 6d 20 33 33 20 31 37 29 29 29 0a 0a 28 (num 33 17)))..(
0800: 74 65 73 74 20 22 33 2e 31 34 31 35 39 22 20 28 test "3.14159" (
0810: 66 6d 74 20 23 66 20 33 2e 31 34 31 35 39 29 29 fmt #f 3.14159))
0820: 0a 28 74 65 73 74 20 22 33 2e 31 34 22 20 28 66 .(test "3.14" (f
0830: 6d 74 20 23 66 20 28 66 69 78 20 32 20 33 2e 31 mt #f (fix 2 3.1
0840: 34 31 35 39 29 29 29 0a 28 74 65 73 74 20 22 33 4159))).(test "3
0850: 2e 31 34 22 20 28 66 6d 74 20 23 66 20 28 66 69 .14" (fmt #f (fi
0860: 78 20 32 20 33 2e 31 34 29 29 29 0a 28 74 65 73 x 2 3.14))).(tes
0870: 74 20 22 33 2e 30 30 22 20 28 66 6d 74 20 23 66 t "3.00" (fmt #f
0880: 20 28 66 69 78 20 32 20 33 2e 29 29 29 0a 28 74 (fix 2 3.))).(t
0890: 65 73 74 20 22 31 2e 31 30 22 20 28 66 6d 74 20 est "1.10" (fmt
08a0: 23 66 20 28 6e 75 6d 20 31 2e 30 39 39 20 31 30 #f (num 1.099 10
08b0: 20 32 29 29 29 0a 28 74 65 73 74 20 22 30 2e 30 2))).(test "0.0
08c0: 30 22 20 28 66 6d 74 20 23 66 20 28 66 69 78 20 0" (fmt #f (fix
08d0: 32 20 31 65 2d 31 37 29 29 29 0a 28 74 65 73 74 2 1e-17))).(test
08e0: 20 22 30 2e 30 30 30 30 30 30 30 30 30 30 22 20 "0.0000000000"
08f0: 28 66 6d 74 20 23 66 20 28 66 69 78 20 31 30 20 (fmt #f (fix 10
0900: 31 65 2d 31 37 29 29 29 0a 28 74 65 73 74 20 22 1e-17))).(test "
0910: 30 2e 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0.00000000000000
0920: 30 30 31 30 30 30 22 20 28 66 6d 74 20 23 66 20 001000" (fmt #f
0930: 28 66 69 78 20 32 30 20 31 65 2d 31 37 29 29 29 (fix 20 1e-17)))
0940: 0a 3b 3b 20 28 74 65 73 74 2d 65 72 72 6f 72 20 .;; (test-error
0950: 28 66 6d 74 20 23 66 20 28 6e 75 6d 20 31 65 2d (fmt #f (num 1e-
0960: 31 37 20 30 29 29 29 0a 28 74 65 73 74 20 22 30 17 0))).(test "0
0970: 2e 30 30 30 30 30 34 22 20 28 66 6d 74 20 23 66 .000004" (fmt #f
0980: 20 28 6e 75 6d 20 30 2e 30 30 30 30 30 34 20 31 (num 0.000004 1
0990: 30 20 36 29 29 29 0a 28 74 65 73 74 20 22 30 2e 0 6))).(test "0.
09a0: 30 30 30 30 30 34 30 22 20 28 66 6d 74 20 23 66 0000040" (fmt #f
09b0: 20 28 6e 75 6d 20 30 2e 30 30 30 30 30 34 20 31 (num 0.000004 1
09c0: 30 20 37 29 29 29 0a 28 74 65 73 74 20 22 30 2e 0 7))).(test "0.
09d0: 30 30 30 30 30 34 30 30 22 20 28 66 6d 74 20 23 00000400" (fmt #
09e0: 66 20 28 6e 75 6d 20 30 2e 30 30 30 30 30 34 20 f (num 0.000004
09f0: 31 30 20 38 29 29 29 0a 3b 3b 20 28 74 65 73 74 10 8))).;; (test
0a00: 20 22 30 2e 30 30 30 30 30 34 22 20 28 66 6d 74 "0.000004" (fmt
0a10: 20 23 66 20 28 6e 75 6d 20 30 2e 30 30 30 30 30 #f (num 0.00000
0a20: 34 29 29 29 0a 0a 28 74 65 73 74 20 22 20 20 20 4)))..(test "
0a30: 33 2e 31 34 31 35 39 22 20 28 66 6d 74 20 23 66 3.14159" (fmt #f
0a40: 20 28 64 65 63 69 6d 61 6c 2d 61 6c 69 67 6e 20 (decimal-align
0a50: 35 20 28 6e 75 6d 20 33 2e 31 34 31 35 39 29 29 5 (num 3.14159))
0a60: 29 29 0a 28 74 65 73 74 20 22 20 20 33 31 2e 34 )).(test " 31.4
0a70: 31 35 39 22 20 28 66 6d 74 20 23 66 20 28 64 65 159" (fmt #f (de
0a80: 63 69 6d 61 6c 2d 61 6c 69 67 6e 20 35 20 28 6e cimal-align 5 (n
0a90: 75 6d 20 33 31 2e 34 31 35 39 29 29 29 29 0a 28 um 31.4159)))).(
0aa0: 74 65 73 74 20 22 20 33 31 34 2e 31 35 39 22 20 test " 314.159"
0ab0: 28 66 6d 74 20 23 66 20 28 64 65 63 69 6d 61 6c (fmt #f (decimal
0ac0: 2d 61 6c 69 67 6e 20 35 20 28 6e 75 6d 20 33 31 -align 5 (num 31
0ad0: 34 2e 31 35 39 29 29 29 29 0a 28 74 65 73 74 20 4.159)))).(test
0ae0: 22 33 31 34 31 2e 35 39 22 20 28 66 6d 74 20 23 "3141.59" (fmt #
0af0: 66 20 28 64 65 63 69 6d 61 6c 2d 61 6c 69 67 6e f (decimal-align
0b00: 20 35 20 28 6e 75 6d 20 33 31 34 31 2e 35 39 29 5 (num 3141.59)
0b10: 29 29 29 0a 28 74 65 73 74 20 22 33 31 34 31 35 ))).(test "31415
0b20: 2e 39 22 20 28 66 6d 74 20 23 66 20 28 64 65 63 .9" (fmt #f (dec
0b30: 69 6d 61 6c 2d 61 6c 69 67 6e 20 35 20 28 6e 75 imal-align 5 (nu
0b40: 6d 20 33 31 34 31 35 2e 39 29 29 29 29 0a 28 74 m 31415.9)))).(t
0b50: 65 73 74 20 22 20 20 2d 33 2e 31 34 31 35 39 22 est " -3.14159"
0b60: 20 28 66 6d 74 20 23 66 20 28 64 65 63 69 6d 61 (fmt #f (decima
0b70: 6c 2d 61 6c 69 67 6e 20 35 20 28 6e 75 6d 20 2d l-align 5 (num -
0b80: 33 2e 31 34 31 35 39 29 29 29 29 0a 28 74 65 73 3.14159)))).(tes
0b90: 74 20 22 20 2d 33 31 2e 34 31 35 39 22 20 28 66 t " -31.4159" (f
0ba0: 6d 74 20 23 66 20 28 64 65 63 69 6d 61 6c 2d 61 mt #f (decimal-a
0bb0: 6c 69 67 6e 20 35 20 28 6e 75 6d 20 2d 33 31 2e lign 5 (num -31.
0bc0: 34 31 35 39 29 29 29 29 0a 28 74 65 73 74 20 22 4159)))).(test "
0bd0: 2d 33 31 34 2e 31 35 39 22 20 28 66 6d 74 20 23 -314.159" (fmt #
0be0: 66 20 28 64 65 63 69 6d 61 6c 2d 61 6c 69 67 6e f (decimal-align
0bf0: 20 35 20 28 6e 75 6d 20 2d 33 31 34 2e 31 35 39 5 (num -314.159
0c00: 29 29 29 29 0a 28 74 65 73 74 20 22 2d 33 31 34 )))).(test "-314
0c10: 31 2e 35 39 22 20 28 66 6d 74 20 23 66 20 28 64 1.59" (fmt #f (d
0c20: 65 63 69 6d 61 6c 2d 61 6c 69 67 6e 20 35 20 28 ecimal-align 5 (
0c30: 6e 75 6d 20 2d 33 31 34 31 2e 35 39 29 29 29 29 num -3141.59))))
0c40: 0a 28 74 65 73 74 20 22 2d 33 31 34 31 35 2e 39 .(test "-31415.9
0c50: 22 20 28 66 6d 74 20 23 66 20 28 64 65 63 69 6d " (fmt #f (decim
0c60: 61 6c 2d 61 6c 69 67 6e 20 35 20 28 6e 75 6d 20 al-align 5 (num
0c70: 2d 33 31 34 31 35 2e 39 29 29 29 29 0a 0a 28 63 -31415.9))))..(c
0c80: 6f 6e 64 0a 20 28 28 65 78 61 63 74 3f 20 28 2f ond. ((exact? (/
0c90: 20 31 20 33 29 29 20 3b 3b 20 65 78 61 63 74 20 1 3)) ;; exact
0ca0: 72 61 74 69 6f 6e 61 6c 73 0a 20 20 28 74 65 73 rationals. (tes
0cb0: 74 20 22 33 33 33 2e 33 33 33 33 33 33 33 33 33 t "333.333333333
0cc0: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
0cd0: 33 33 33 33 33 22 20 28 66 6d 74 20 23 66 20 28 33333" (fmt #f (
0ce0: 66 69 78 20 33 30 20 31 30 30 30 2f 33 29 29 29 fix 30 1000/3)))
0cf0: 0a 20 20 28 74 65 73 74 20 20 22 33 33 2e 33 33 . (test "33.33
0d00: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
0d10: 33 33 33 33 33 33 33 33 33 33 33 33 22 20 28 66 333333333333" (f
0d20: 6d 74 20 23 66 20 28 66 69 78 20 33 30 20 31 30 mt #f (fix 30 10
0d30: 30 2f 33 29 29 29 0a 20 20 28 74 65 73 74 20 20 0/3))). (test
0d40: 20 22 33 2e 33 33 33 33 33 33 33 33 33 33 33 33 "3.333333333333
0d50: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
0d60: 33 33 22 20 28 66 6d 74 20 23 66 20 28 66 69 78 33" (fmt #f (fix
0d70: 20 33 30 20 31 30 2f 33 29 29 29 0a 20 20 28 74 30 10/3))). (t
0d80: 65 73 74 20 20 20 22 30 2e 33 33 33 33 33 33 33 est "0.3333333
0d90: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
0da0: 33 33 33 33 33 33 33 22 20 28 66 6d 74 20 23 66 3333333" (fmt #f
0db0: 20 28 66 69 78 20 33 30 20 31 2f 33 29 29 29 0a (fix 30 1/3))).
0dc0: 20 20 28 74 65 73 74 20 20 20 22 30 2e 30 33 33 (test "0.033
0dd0: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
0de0: 33 33 33 33 33 33 33 33 33 33 33 22 20 28 66 6d 33333333333" (fm
0df0: 74 20 23 66 20 28 66 69 78 20 33 30 20 31 2f 33 t #f (fix 30 1/3
0e00: 30 29 29 29 0a 20 20 28 74 65 73 74 20 20 20 22 0))). (test "
0e10: 30 2e 30 30 33 33 33 33 33 33 33 33 33 33 33 33 0.00333333333333
0e20: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
0e30: 22 20 28 66 6d 74 20 23 66 20 28 66 69 78 20 33 " (fmt #f (fix 3
0e40: 30 20 31 2f 33 30 30 29 29 29 0a 20 20 28 74 65 0 1/300))). (te
0e50: 73 74 20 20 20 22 30 2e 30 30 30 33 33 33 33 33 st "0.00033333
0e60: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
0e70: 33 33 33 33 33 33 22 20 28 66 6d 74 20 23 66 20 333333" (fmt #f
0e80: 28 66 69 78 20 33 30 20 31 2f 33 30 30 30 29 29 (fix 30 1/3000))
0e90: 29 0a 20 20 28 74 65 73 74 20 20 20 22 30 2e 36 ). (test "0.6
0ea0: 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 6666666666666666
0eb0: 36 36 36 36 36 36 36 36 36 36 36 36 37 22 20 28 6666666666667" (
0ec0: 66 6d 74 20 23 66 20 28 66 69 78 20 33 30 20 32 fmt #f (fix 30 2
0ed0: 2f 33 29 29 29 0a 20 20 28 74 65 73 74 20 20 20 /3))). (test
0ee0: 22 30 2e 30 39 30 39 30 39 30 39 30 39 30 39 30 "0.0909090909090
0ef0: 39 30 39 30 39 30 39 30 39 30 39 30 39 30 39 30 9090909090909090
0f00: 39 22 20 28 66 6d 74 20 23 66 20 28 66 69 78 20 9" (fmt #f (fix
0f10: 33 30 20 31 2f 31 31 29 29 29 0a 20 20 28 74 65 30 1/11))). (te
0f20: 73 74 20 20 20 22 31 2e 34 32 38 35 37 31 34 32 st "1.42857142
0f30: 38 35 37 31 34 32 38 35 37 31 34 32 38 35 37 31 8571428571428571
0f40: 34 32 38 35 37 31 22 20 28 66 6d 74 20 23 66 20 428571" (fmt #f
0f50: 28 66 69 78 20 33 30 20 31 30 2f 37 29 29 29 0a (fix 30 10/7))).
0f60: 20 20 28 74 65 73 74 20 22 30 2e 31 32 33 34 35 (test "0.12345
0f70: 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 6789012345678901
0f80: 32 33 34 35 36 37 38 39 30 22 0a 20 20 20 20 20 234567890".
0f90: 20 28 66 6d 74 20 23 66 20 28 66 69 78 20 33 30 (fmt #f (fix 30
0fa0: 20 28 2f 20 20 31 32 33 34 35 36 37 38 39 30 31 (/ 12345678901
0fb0: 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 2345678901234567
0fc0: 38 39 30 0a 20 20 20 20 20 20 20 20 20 20 20 20 890.
0fd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 31 30 30 100
0fe0: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
0ff0: 30 30 30 30 30 30 30 30 30 30 30 30 29 29 29 29 000000000000))))
1000: 0a 20 20 28 74 65 73 74 20 20 22 20 33 33 33 2e . (test " 333.
1010: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
1020: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 22 20 33333333333333"
1030: 28 66 6d 74 20 23 66 20 28 64 65 63 69 6d 61 6c (fmt #f (decimal
1040: 2d 61 6c 69 67 6e 20 35 20 28 66 69 78 20 33 30 -align 5 (fix 30
1050: 20 31 30 30 30 2f 33 29 29 29 29 0a 20 20 28 74 1000/3)))). (t
1060: 65 73 74 20 20 22 20 20 33 33 2e 33 33 33 33 33 est " 33.33333
1070: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
1080: 33 33 33 33 33 33 33 33 33 22 20 28 66 6d 74 20 333333333" (fmt
1090: 23 66 20 28 64 65 63 69 6d 61 6c 2d 61 6c 69 67 #f (decimal-alig
10a0: 6e 20 35 20 28 66 69 78 20 33 30 20 31 30 30 2f n 5 (fix 30 100/
10b0: 33 29 29 29 29 0a 20 20 28 74 65 73 74 20 20 22 3)))). (test "
10c0: 20 20 20 33 2e 33 33 33 33 33 33 33 33 33 33 33 3.33333333333
10d0: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
10e0: 33 33 33 22 20 28 66 6d 74 20 23 66 20 28 64 65 333" (fmt #f (de
10f0: 63 69 6d 61 6c 2d 61 6c 69 67 6e 20 35 20 28 66 cimal-align 5 (f
1100: 69 78 20 33 30 20 31 30 2f 33 29 29 29 29 0a 20 ix 30 10/3)))).
1110: 20 28 74 65 73 74 20 20 22 20 20 20 30 2e 33 33 (test " 0.33
1120: 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3333333333333333
1130: 33 33 33 33 33 33 33 33 33 33 33 33 22 20 28 66 333333333333" (f
1140: 6d 74 20 23 66 20 28 64 65 63 69 6d 61 6c 2d 61 mt #f (decimal-a
1150: 6c 69 67 6e 20 35 20 28 66 69 78 20 33 30 20 31 lign 5 (fix 30 1
1160: 2f 33 29 29 29 29 0a 20 20 29 29 0a 0a 28 74 65 /3)))). ))..(te
1170: 73 74 20 22 31 31 2e 37 35 22 20 28 66 6d 74 20 st "11.75" (fmt
1180: 23 66 20 28 6e 75 6d 20 28 2f 20 34 37 20 34 29 #f (num (/ 47 4)
1190: 20 31 30 20 32 29 29 29 0a 28 74 65 73 74 20 22 10 2))).(test "
11a0: 2d 31 31 2e 37 35 22 20 28 66 6d 74 20 23 66 20 -11.75" (fmt #f
11b0: 28 6e 75 6d 20 28 2f 20 2d 34 37 20 34 29 20 31 (num (/ -47 4) 1
11c0: 30 20 32 29 29 29 0a 0a 28 74 65 73 74 20 22 28 0 2)))..(test "(
11d0: 23 78 31 31 20 23 78 32 32 20 23 78 33 33 29 22 #x11 #x22 #x33)"
11e0: 20 28 66 6d 74 20 23 66 20 28 72 61 64 69 78 20 (fmt #f (radix
11f0: 31 36 20 27 28 23 78 31 31 20 23 78 32 32 20 23 16 '(#x11 #x22 #
1200: 78 33 33 29 29 29 29 0a 0a 28 74 65 73 74 20 22 x33))))..(test "
1210: 32 39 39 2c 37 39 32 2c 34 35 38 22 20 28 66 6d 299,792,458" (fm
1220: 74 20 23 66 20 28 6e 75 6d 20 32 39 39 37 39 32 t #f (num 299792
1230: 34 35 38 20 31 30 20 23 66 20 23 66 20 23 74 29 458 10 #f #f #t)
1240: 29 29 0a 28 74 65 73 74 20 22 32 39 39 2c 37 39 )).(test "299,79
1250: 32 2c 34 35 38 22 20 28 66 6d 74 20 23 66 20 28 2,458" (fmt #f (
1260: 6e 75 6d 2f 63 6f 6d 6d 61 20 32 39 39 37 39 32 num/comma 299792
1270: 34 35 38 29 29 29 0a 28 74 65 73 74 20 22 32 39 458))).(test "29
1280: 39 2e 37 39 32 2e 34 35 38 22 20 28 66 6d 74 20 9.792.458" (fmt
1290: 23 66 20 28 63 6f 6d 6d 61 2d 63 68 61 72 20 23 #f (comma-char #
12a0: 5c 2e 20 28 6e 75 6d 2f 63 6f 6d 6d 61 20 32 39 \. (num/comma 29
12b0: 39 37 39 32 34 35 38 29 29 29 29 0a 28 74 65 73 9792458)))).(tes
12c0: 74 20 22 32 39 39 2e 37 39 32 2e 34 35 38 2c 30 t "299.792.458,0
12d0: 22 20 28 66 6d 74 20 23 66 20 28 63 6f 6d 6d 61 " (fmt #f (comma
12e0: 2d 63 68 61 72 20 23 5c 2e 20 28 6e 75 6d 2f 63 -char #\. (num/c
12f0: 6f 6d 6d 61 20 32 39 39 37 39 32 34 35 38 2e 30 omma 299792458.0
1300: 29 29 29 29 0a 0a 28 74 65 73 74 20 22 31 30 30 ))))..(test "100
1310: 2c 30 30 30 22 20 28 66 6d 74 20 23 66 20 28 6e ,000" (fmt #f (n
1320: 75 6d 20 31 30 30 30 30 30 20 31 30 20 30 20 23 um 100000 10 0 #
1330: 66 20 33 29 29 29 0a 28 74 65 73 74 20 22 31 30 f 3))).(test "10
1340: 30 2c 30 30 30 2e 30 22 20 28 66 6d 74 20 23 66 0,000.0" (fmt #f
1350: 20 28 6e 75 6d 20 31 30 30 30 30 30 20 31 30 20 (num 100000 10
1360: 31 20 23 66 20 33 29 29 29 0a 28 74 65 73 74 20 1 #f 3))).(test
1370: 22 31 30 30 2c 30 30 30 2e 30 30 22 20 28 66 6d "100,000.00" (fm
1380: 74 20 23 66 20 28 6e 75 6d 20 31 30 30 30 30 30 t #f (num 100000
1390: 20 31 30 20 32 20 23 66 20 33 29 29 29 0a 0a 28 10 2 #f 3)))..(
13a0: 74 65 73 74 20 22 31 2e 32 33 22 20 28 66 6d 74 test "1.23" (fmt
13b0: 20 23 66 20 28 66 69 78 20 32 20 28 6e 75 6d 2f #f (fix 2 (num/
13c0: 66 69 74 20 34 20 31 2e 32 33 34 35 29 29 29 29 fit 4 1.2345))))
13d0: 0a 28 74 65 73 74 20 22 31 2e 30 30 22 20 28 66 .(test "1.00" (f
13e0: 6d 74 20 23 66 20 28 66 69 78 20 32 20 28 6e 75 mt #f (fix 2 (nu
13f0: 6d 2f 66 69 74 20 34 20 31 29 29 29 29 0a 28 74 m/fit 4 1)))).(t
1400: 65 73 74 20 22 23 2e 23 23 22 20 28 66 6d 74 20 est "#.##" (fmt
1410: 23 66 20 28 66 69 78 20 32 20 28 6e 75 6d 2f 66 #f (fix 2 (num/f
1420: 69 74 20 34 20 31 32 2e 33 34 35 29 29 29 29 0a it 4 12.345)))).
1430: 0a 3b 3b 20 28 63 6f 6e 64 0a 3b 3b 20 20 28 28 .;; (cond.;; ((
1440: 66 65 61 74 75 72 65 3f 20 27 66 75 6c 6c 2d 6e feature? 'full-n
1450: 75 6d 65 72 69 63 2d 74 6f 77 65 72 29 0a 3b 3b umeric-tower).;;
1460: 20 20 20 28 74 65 73 74 20 22 31 2b 32 69 22 20 (test "1+2i"
1470: 28 66 6d 74 20 23 66 20 28 73 74 72 69 6e 67 2d (fmt #f (string-
1480: 3e 6e 75 6d 62 65 72 20 22 31 2b 32 69 22 29 29 >number "1+2i"))
1490: 29 0a 3b 3b 20 20 20 28 74 65 73 74 20 22 31 2b ).;; (test "1+
14a0: 32 69 22 20 28 66 6d 74 20 23 66 20 28 6e 75 6d 2i" (fmt #f (num
14b0: 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 (string->number
14c0: 20 22 31 2b 32 69 22 29 29 29 29 0a 3b 3b 20 20 "1+2i")))).;;
14d0: 20 28 74 65 73 74 20 22 31 2e 30 30 2b 32 2e 30 (test "1.00+2.0
14e0: 30 69 22 20 28 66 6d 74 20 23 66 20 28 66 69 78 0i" (fmt #f (fix
14f0: 20 32 20 28 6e 75 6d 20 28 73 74 72 69 6e 67 2d 2 (num (string-
1500: 3e 6e 75 6d 62 65 72 20 22 31 2b 32 69 22 29 29 >number "1+2i"))
1510: 29 29 29 0a 3b 3b 20 20 20 28 74 65 73 74 20 22 ))).;; (test "
1520: 33 2e 31 34 2b 32 2e 30 30 69 22 20 28 66 6d 74 3.14+2.00i" (fmt
1530: 20 23 66 20 28 66 69 78 20 32 20 28 6e 75 6d 20 #f (fix 2 (num
1540: 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 (string->number
1550: 22 33 2e 31 34 31 35 39 2b 32 69 22 29 29 29 29 "3.14159+2i"))))
1560: 29 29 29 0a 0a 28 74 65 73 74 20 22 33 2e 39 4b )))..(test "3.9K
1570: 69 22 20 28 66 6d 74 20 23 66 20 28 6e 75 6d 2f i" (fmt #f (num/
1580: 73 69 20 33 39 38 36 29 29 29 0a 28 74 65 73 74 si 3986))).(test
1590: 20 22 34 6b 22 20 28 66 6d 74 20 23 66 20 28 6e "4k" (fmt #f (n
15a0: 75 6d 2f 73 69 20 33 39 38 36 20 31 30 30 30 29 um/si 3986 1000)
15b0: 29 29 0a 28 74 65 73 74 20 22 36 30 38 22 20 28 )).(test "608" (
15c0: 66 6d 74 20 23 66 20 28 6e 75 6d 2f 73 69 20 36 fmt #f (num/si 6
15d0: 30 38 29 29 29 0a 28 74 65 73 74 20 22 33 47 22 08))).(test "3G"
15e0: 20 28 66 6d 74 20 23 66 20 28 6e 75 6d 2f 73 69 (fmt #f (num/si
15f0: 20 31 32 33 34 35 2e 31 32 33 35 35 20 31 36 29 12345.12355 16)
1600: 29 29 0a 0a 3b 3b 20 70 61 64 64 69 6e 67 2f 74 ))..;; padding/t
1610: 72 69 6d 6d 69 6e 67 0a 0a 28 74 65 73 74 20 22 rimming..(test "
1620: 61 62 63 20 20 22 20 28 66 6d 74 20 23 66 20 28 abc " (fmt #f (
1630: 70 61 64 20 35 20 22 61 62 63 22 29 29 29 0a 28 pad 5 "abc"))).(
1640: 74 65 73 74 20 22 20 20 61 62 63 22 20 28 66 6d test " abc" (fm
1650: 74 20 23 66 20 28 70 61 64 2f 6c 65 66 74 20 35 t #f (pad/left 5
1660: 20 22 61 62 63 22 29 29 29 0a 28 74 65 73 74 20 "abc"))).(test
1670: 22 20 61 62 63 20 22 20 28 66 6d 74 20 23 66 20 " abc " (fmt #f
1680: 28 70 61 64 2f 62 6f 74 68 20 35 20 22 61 62 63 (pad/both 5 "abc
1690: 22 29 29 29 0a 28 74 65 73 74 20 22 61 62 63 64 "))).(test "abcd
16a0: 65 22 20 28 66 6d 74 20 23 66 20 28 70 61 64 20 e" (fmt #f (pad
16b0: 35 20 22 61 62 63 64 65 22 29 29 29 0a 28 74 65 5 "abcde"))).(te
16c0: 73 74 20 22 61 62 63 64 65 66 22 20 28 66 6d 74 st "abcdef" (fmt
16d0: 20 23 66 20 28 70 61 64 20 35 20 22 61 62 63 64 #f (pad 5 "abcd
16e0: 65 66 22 29 29 29 0a 0a 28 74 65 73 74 20 22 61 ef")))..(test "a
16f0: 62 63 22 20 28 66 6d 74 20 23 66 20 28 74 72 69 bc" (fmt #f (tri
1700: 6d 20 33 20 22 61 62 63 64 65 22 29 29 29 0a 28 m 3 "abcde"))).(
1710: 74 65 73 74 20 22 61 62 63 22 20 28 66 6d 74 20 test "abc" (fmt
1720: 23 66 20 28 74 72 69 6d 2f 6c 65 6e 67 74 68 20 #f (trim/length
1730: 33 20 22 61 62 63 64 65 22 29 29 29 0a 28 74 65 3 "abcde"))).(te
1740: 73 74 20 22 61 62 63 22 20 28 66 6d 74 20 23 66 st "abc" (fmt #f
1750: 20 28 74 72 69 6d 2f 6c 65 6e 67 74 68 20 33 20 (trim/length 3
1760: 22 61 62 63 5c 6e 64 65 22 29 29 29 0a 28 74 65 "abc\nde"))).(te
1770: 73 74 20 22 63 64 65 22 20 28 66 6d 74 20 23 66 st "cde" (fmt #f
1780: 20 28 74 72 69 6d 2f 6c 65 66 74 20 33 20 22 61 (trim/left 3 "a
1790: 62 63 64 65 22 29 29 29 0a 28 74 65 73 74 20 22 bcde"))).(test "
17a0: 62 63 64 22 20 28 66 6d 74 20 23 66 20 28 74 72 bcd" (fmt #f (tr
17b0: 69 6d 2f 62 6f 74 68 20 33 20 22 61 62 63 64 65 im/both 3 "abcde
17c0: 22 29 29 29 0a 0a 28 74 65 73 74 20 22 70 72 65 ")))..(test "pre
17d0: 66 69 78 3a 20 61 62 63 22 20 28 66 6d 74 20 23 fix: abc" (fmt #
17e0: 66 20 22 70 72 65 66 69 78 3a 20 22 20 28 74 72 f "prefix: " (tr
17f0: 69 6d 20 33 20 22 61 62 63 64 65 22 29 29 29 0a im 3 "abcde"))).
1800: 28 74 65 73 74 20 22 70 72 65 66 69 78 3a 20 61 (test "prefix: a
1810: 62 63 22 20 28 66 6d 74 20 23 66 20 22 70 72 65 bc" (fmt #f "pre
1820: 66 69 78 3a 20 22 20 28 74 72 69 6d 2f 6c 65 6e fix: " (trim/len
1830: 67 74 68 20 33 20 22 61 62 63 64 65 22 29 29 29 gth 3 "abcde")))
1840: 0a 28 74 65 73 74 20 22 70 72 65 66 69 78 3a 20 .(test "prefix:
1850: 61 62 63 22 20 28 66 6d 74 20 23 66 20 22 70 72 abc" (fmt #f "pr
1860: 65 66 69 78 3a 20 22 20 28 74 72 69 6d 2f 6c 65 efix: " (trim/le
1870: 6e 67 74 68 20 33 20 22 61 62 63 5c 6e 64 65 22 ngth 3 "abc\nde"
1880: 29 29 29 0a 28 74 65 73 74 20 22 70 72 65 66 69 ))).(test "prefi
1890: 78 3a 20 63 64 65 22 20 28 66 6d 74 20 23 66 20 x: cde" (fmt #f
18a0: 22 70 72 65 66 69 78 3a 20 22 20 28 74 72 69 6d "prefix: " (trim
18b0: 2f 6c 65 66 74 20 33 20 22 61 62 63 64 65 22 29 /left 3 "abcde")
18c0: 29 29 0a 28 74 65 73 74 20 22 70 72 65 66 69 78 )).(test "prefix
18d0: 3a 20 62 63 64 22 20 28 66 6d 74 20 23 66 20 22 : bcd" (fmt #f "
18e0: 70 72 65 66 69 78 3a 20 22 20 28 74 72 69 6d 2f prefix: " (trim/
18f0: 62 6f 74 68 20 33 20 22 61 62 63 64 65 22 29 29 both 3 "abcde"))
1900: 29 0a 0a 28 74 65 73 74 20 22 61 62 63 64 65 22 )..(test "abcde"
1910: 20 28 66 6d 74 20 23 66 20 28 65 6c 6c 69 70 73 (fmt #f (ellips
1920: 65 73 20 22 2e 2e 2e 22 20 28 74 72 69 6d 20 35 es "..." (trim 5
1930: 20 22 61 62 63 64 65 22 29 29 29 29 0a 28 74 65 "abcde")))).(te
1940: 73 74 20 22 61 62 2e 2e 2e 22 20 28 66 6d 74 20 st "ab..." (fmt
1950: 23 66 20 28 65 6c 6c 69 70 73 65 73 20 22 2e 2e #f (ellipses "..
1960: 2e 22 20 28 74 72 69 6d 20 35 20 22 61 62 63 64 ." (trim 5 "abcd
1970: 65 66 22 29 29 29 29 0a 28 74 65 73 74 20 22 61 ef")))).(test "a
1980: 62 63 2e 2e 2e 22 20 28 66 6d 74 20 23 66 20 28 bc..." (fmt #f (
1990: 65 6c 6c 69 70 73 65 73 20 22 2e 2e 2e 22 20 28 ellipses "..." (
19a0: 74 72 69 6d 20 36 20 22 61 62 63 64 65 66 67 22 trim 6 "abcdefg"
19b0: 29 29 29 29 0a 28 74 65 73 74 20 22 61 62 63 64 )))).(test "abcd
19c0: 65 22 20 28 66 6d 74 20 23 66 20 28 65 6c 6c 69 e" (fmt #f (elli
19d0: 70 73 65 73 20 22 2e 2e 2e 22 20 28 74 72 69 6d pses "..." (trim
19e0: 2f 6c 65 66 74 20 35 20 22 61 62 63 64 65 22 29 /left 5 "abcde")
19f0: 29 29 29 0a 28 74 65 73 74 20 22 2e 2e 2e 65 66 ))).(test "...ef
1a00: 22 20 28 66 6d 74 20 23 66 20 28 65 6c 6c 69 70 " (fmt #f (ellip
1a10: 73 65 73 20 22 2e 2e 2e 22 20 28 74 72 69 6d 2f ses "..." (trim/
1a20: 6c 65 66 74 20 35 20 22 61 62 63 64 65 66 22 29 left 5 "abcdef")
1a30: 29 29 29 0a 28 74 65 73 74 20 22 2e 2e 2e 65 66 ))).(test "...ef
1a40: 67 22 20 28 66 6d 74 20 23 66 20 28 65 6c 6c 69 g" (fmt #f (elli
1a50: 70 73 65 73 20 22 2e 2e 2e 22 20 28 74 72 69 6d pses "..." (trim
1a60: 2f 6c 65 66 74 20 36 20 22 61 62 63 64 65 66 67 /left 6 "abcdefg
1a70: 22 29 29 29 29 0a 28 74 65 73 74 20 22 61 62 63 ")))).(test "abc
1a80: 64 65 66 67 22 20 28 66 6d 74 20 23 66 20 28 65 defg" (fmt #f (e
1a90: 6c 6c 69 70 73 65 73 20 22 2e 2e 2e 22 20 28 74 llipses "..." (t
1aa0: 72 69 6d 2f 62 6f 74 68 20 37 20 22 61 62 63 64 rim/both 7 "abcd
1ab0: 65 66 67 22 29 29 29 29 0a 28 74 65 73 74 20 22 efg")))).(test "
1ac0: 2e 2e 2e 64 2e 2e 2e 22 20 28 66 6d 74 20 23 66 ...d..." (fmt #f
1ad0: 20 28 65 6c 6c 69 70 73 65 73 20 22 2e 2e 2e 22 (ellipses "..."
1ae0: 20 28 74 72 69 6d 2f 62 6f 74 68 20 37 20 22 61 (trim/both 7 "a
1af0: 62 63 64 65 66 67 68 22 29 29 29 29 0a 28 74 65 bcdefgh")))).(te
1b00: 73 74 20 22 2e 2e 2e 65 2e 2e 2e 22 20 28 66 6d st "...e..." (fm
1b10: 74 20 23 66 20 28 65 6c 6c 69 70 73 65 73 20 22 t #f (ellipses "
1b20: 2e 2e 2e 22 20 28 74 72 69 6d 2f 62 6f 74 68 20 ..." (trim/both
1b30: 37 20 22 61 62 63 64 65 66 67 68 69 22 29 29 29 7 "abcdefghi")))
1b40: 29 0a 0a 28 74 65 73 74 20 22 61 62 63 20 20 22 )..(test "abc "
1b50: 20 28 66 6d 74 20 23 66 20 28 66 69 74 20 35 20 (fmt #f (fit 5
1b60: 22 61 62 63 22 29 29 29 0a 28 74 65 73 74 20 22 "abc"))).(test "
1b70: 20 20 61 62 63 22 20 28 66 6d 74 20 23 66 20 28 abc" (fmt #f (
1b80: 66 69 74 2f 6c 65 66 74 20 35 20 22 61 62 63 22 fit/left 5 "abc"
1b90: 29 29 29 0a 28 74 65 73 74 20 22 20 61 62 63 20 ))).(test " abc
1ba0: 22 20 28 66 6d 74 20 23 66 20 28 66 69 74 2f 62 " (fmt #f (fit/b
1bb0: 6f 74 68 20 35 20 22 61 62 63 22 29 29 29 0a 28 oth 5 "abc"))).(
1bc0: 74 65 73 74 20 22 61 62 63 64 65 22 20 28 66 6d test "abcde" (fm
1bd0: 74 20 23 66 20 28 66 69 74 20 35 20 22 61 62 63 t #f (fit 5 "abc
1be0: 64 65 22 29 29 29 0a 28 74 65 73 74 20 22 61 62 de"))).(test "ab
1bf0: 63 64 65 22 20 28 66 6d 74 20 23 66 20 28 66 69 cde" (fmt #f (fi
1c00: 74 2f 6c 65 66 74 20 35 20 22 61 62 63 64 65 22 t/left 5 "abcde"
1c10: 29 29 29 0a 28 74 65 73 74 20 22 61 62 63 64 65 ))).(test "abcde
1c20: 22 20 28 66 6d 74 20 23 66 20 28 66 69 74 2f 62 " (fmt #f (fit/b
1c30: 6f 74 68 20 35 20 22 61 62 63 64 65 22 29 29 29 oth 5 "abcde")))
1c40: 0a 28 74 65 73 74 20 22 61 62 63 64 65 22 20 28 .(test "abcde" (
1c50: 66 6d 74 20 23 66 20 28 66 69 74 20 35 20 22 61 fmt #f (fit 5 "a
1c60: 62 63 64 65 66 67 68 22 29 29 29 0a 28 74 65 73 bcdefgh"))).(tes
1c70: 74 20 22 64 65 66 67 68 22 20 28 66 6d 74 20 23 t "defgh" (fmt #
1c80: 66 20 28 66 69 74 2f 6c 65 66 74 20 35 20 22 61 f (fit/left 5 "a
1c90: 62 63 64 65 66 67 68 22 29 29 29 0a 28 74 65 73 bcdefgh"))).(tes
1ca0: 74 20 22 63 64 65 66 67 22 20 28 66 6d 74 20 23 t "cdefg" (fmt #
1cb0: 66 20 28 66 69 74 2f 62 6f 74 68 20 35 20 22 61 f (fit/both 5 "a
1cc0: 62 63 64 65 66 67 68 22 29 29 29 0a 0a 28 74 65 bcdefgh")))..(te
1cd0: 73 74 20 22 70 72 65 66 69 78 3a 20 61 62 63 20 st "prefix: abc
1ce0: 20 22 20 28 66 6d 74 20 23 66 20 22 70 72 65 66 " (fmt #f "pref
1cf0: 69 78 3a 20 22 20 28 66 69 74 20 35 20 22 61 62 ix: " (fit 5 "ab
1d00: 63 22 29 29 29 0a 28 74 65 73 74 20 22 70 72 65 c"))).(test "pre
1d10: 66 69 78 3a 20 20 20 61 62 63 22 20 28 66 6d 74 fix: abc" (fmt
1d20: 20 23 66 20 22 70 72 65 66 69 78 3a 20 22 20 28 #f "prefix: " (
1d30: 66 69 74 2f 6c 65 66 74 20 35 20 22 61 62 63 22 fit/left 5 "abc"
1d40: 29 29 29 0a 28 74 65 73 74 20 22 70 72 65 66 69 ))).(test "prefi
1d50: 78 3a 20 20 61 62 63 20 22 20 28 66 6d 74 20 23 x: abc " (fmt #
1d60: 66 20 22 70 72 65 66 69 78 3a 20 22 20 28 66 69 f "prefix: " (fi
1d70: 74 2f 62 6f 74 68 20 35 20 22 61 62 63 22 29 29 t/both 5 "abc"))
1d80: 29 0a 28 74 65 73 74 20 22 70 72 65 66 69 78 3a ).(test "prefix:
1d90: 20 61 62 63 64 65 22 20 28 66 6d 74 20 23 66 20 abcde" (fmt #f
1da0: 22 70 72 65 66 69 78 3a 20 22 20 28 66 69 74 20 "prefix: " (fit
1db0: 35 20 22 61 62 63 64 65 22 29 29 29 0a 28 74 65 5 "abcde"))).(te
1dc0: 73 74 20 22 70 72 65 66 69 78 3a 20 61 62 63 64 st "prefix: abcd
1dd0: 65 22 20 28 66 6d 74 20 23 66 20 22 70 72 65 66 e" (fmt #f "pref
1de0: 69 78 3a 20 22 20 28 66 69 74 2f 6c 65 66 74 20 ix: " (fit/left
1df0: 35 20 22 61 62 63 64 65 22 29 29 29 0a 28 74 65 5 "abcde"))).(te
1e00: 73 74 20 22 70 72 65 66 69 78 3a 20 61 62 63 64 st "prefix: abcd
1e10: 65 22 20 28 66 6d 74 20 23 66 20 22 70 72 65 66 e" (fmt #f "pref
1e20: 69 78 3a 20 22 20 28 66 69 74 2f 62 6f 74 68 20 ix: " (fit/both
1e30: 35 20 22 61 62 63 64 65 22 29 29 29 0a 28 74 65 5 "abcde"))).(te
1e40: 73 74 20 22 70 72 65 66 69 78 3a 20 61 62 63 64 st "prefix: abcd
1e50: 65 22 20 28 66 6d 74 20 23 66 20 22 70 72 65 66 e" (fmt #f "pref
1e60: 69 78 3a 20 22 20 28 66 69 74 20 35 20 22 61 62 ix: " (fit 5 "ab
1e70: 63 64 65 66 67 68 22 29 29 29 0a 28 74 65 73 74 cdefgh"))).(test
1e80: 20 22 70 72 65 66 69 78 3a 20 64 65 66 67 68 22 "prefix: defgh"
1e90: 20 28 66 6d 74 20 23 66 20 22 70 72 65 66 69 78 (fmt #f "prefix
1ea0: 3a 20 22 20 28 66 69 74 2f 6c 65 66 74 20 35 20 : " (fit/left 5
1eb0: 22 61 62 63 64 65 66 67 68 22 29 29 29 0a 28 74 "abcdefgh"))).(t
1ec0: 65 73 74 20 22 70 72 65 66 69 78 3a 20 63 64 65 est "prefix: cde
1ed0: 66 67 22 20 28 66 6d 74 20 23 66 20 22 70 72 65 fg" (fmt #f "pre
1ee0: 66 69 78 3a 20 22 20 28 66 69 74 2f 62 6f 74 68 fix: " (fit/both
1ef0: 20 35 20 22 61 62 63 64 65 66 67 68 22 29 29 29 5 "abcdefgh")))
1f00: 0a 0a 28 74 65 73 74 20 22 61 62 63 5c 6e 31 32 ..(test "abc\n12
1f10: 33 5c 6e 22 20 28 66 6d 74 20 23 66 20 28 66 6d 3\n" (fmt #f (fm
1f20: 74 2d 6a 6f 69 6e 2f 73 75 66 66 69 78 20 28 63 t-join/suffix (c
1f30: 75 74 20 74 72 69 6d 20 33 20 3c 3e 29 20 28 73 ut trim 3 <>) (s
1f40: 74 72 69 6e 67 2d 73 70 6c 69 74 20 22 61 62 63 tring-split "abc
1f50: 64 65 66 5c 6e 31 32 33 34 35 36 5c 6e 22 20 22 def\n123456\n" "
1f60: 5c 6e 22 29 20 6e 6c 29 29 29 0a 0a 3b 3b 20 75 \n") nl)))..;; u
1f70: 74 69 6c 69 74 69 65 73 0a 0a 28 74 65 73 74 20 tilities..(test
1f80: 22 31 20 32 20 33 22 20 28 66 6d 74 20 23 66 20 "1 2 3" (fmt #f
1f90: 28 66 6d 74 2d 6a 6f 69 6e 20 64 73 70 20 27 28 (fmt-join dsp '(
1fa0: 31 20 32 20 33 29 20 22 20 22 29 29 29 0a 0a 3b 1 2 3) " ")))..;
1fb0: 3b 20 73 68 61 72 65 64 20 73 74 72 75 63 74 75 ; shared structu
1fc0: 72 65 73 0a 0a 28 74 65 73 74 20 22 23 30 3d 28 res..(test "#0=(
1fd0: 31 20 2e 20 23 30 23 29 22 0a 20 20 20 20 28 66 1 . #0#)". (f
1fe0: 6d 74 20 23 66 20 28 77 72 74 20 28 6c 65 74 20 mt #f (wrt (let
1ff0: 28 28 6f 6e 65 73 20 28 6c 69 73 74 20 31 29 29 ((ones (list 1))
2000: 29 20 28 73 65 74 2d 63 64 72 21 20 6f 6e 65 73 ) (set-cdr! ones
2010: 20 6f 6e 65 73 29 20 6f 6e 65 73 29 29 29 29 0a ones) ones)))).
2020: 28 74 65 73 74 20 22 28 30 20 2e 20 23 30 3d 28 (test "(0 . #0=(
2030: 31 20 2e 20 23 30 23 29 29 22 0a 20 20 20 20 28 1 . #0#))". (
2040: 66 6d 74 20 23 66 20 28 77 72 74 20 28 6c 65 74 fmt #f (wrt (let
2050: 20 28 28 6f 6e 65 73 20 28 6c 69 73 74 20 31 29 ((ones (list 1)
2060: 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )).
2070: 20 20 20 20 20 20 28 73 65 74 2d 63 64 72 21 20 (set-cdr!
2080: 6f 6e 65 73 20 6f 6e 65 73 29 0a 20 20 20 20 20 ones ones).
2090: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 63 (c
20a0: 6f 6e 73 20 30 20 6f 6e 65 73 29 29 29 29 29 0a ons 0 ones))))).
20b0: 28 74 65 73 74 20 22 28 73 79 6d 20 2e 20 23 30 (test "(sym . #0
20c0: 3d 28 73 79 6d 20 2e 20 23 30 23 29 29 22 0a 20 =(sym . #0#))".
20d0: 20 20 20 28 66 6d 74 20 23 66 20 28 77 72 74 20 (fmt #f (wrt
20e0: 28 6c 65 74 20 28 28 73 79 6d 73 20 28 6c 69 73 (let ((syms (lis
20f0: 74 20 27 73 79 6d 29 29 29 0a 20 20 20 20 20 20 t 'sym))).
2100: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 73 65 (se
2110: 74 2d 63 64 72 21 20 73 79 6d 73 20 73 79 6d 73 t-cdr! syms syms
2120: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ).
2130: 20 20 20 20 20 28 63 6f 6e 73 20 27 73 79 6d 20 (cons 'sym
2140: 73 79 6d 73 29 29 29 29 29 0a 28 74 65 73 74 20 syms))))).(test
2150: 22 28 23 30 3d 28 31 20 2e 20 23 30 23 29 20 23 "(#0=(1 . #0#) #
2160: 31 3d 28 32 20 2e 20 23 31 23 29 29 22 0a 20 20 1=(2 . #1#))".
2170: 20 20 28 66 6d 74 20 23 66 20 28 77 72 74 20 28 (fmt #f (wrt (
2180: 6c 65 74 20 28 28 6f 6e 65 73 20 28 6c 69 73 74 let ((ones (list
2190: 20 31 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 1)).
21a0: 20 20 20 20 20 20 20 20 20 20 20 20 28 74 77 6f (two
21b0: 73 20 28 6c 69 73 74 20 32 29 29 29 0a 20 20 20 s (list 2))).
21c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
21d0: 28 73 65 74 2d 63 64 72 21 20 6f 6e 65 73 20 6f (set-cdr! ones o
21e0: 6e 65 73 29 0a 20 20 20 20 20 20 20 20 20 20 20 nes).
21f0: 20 20 20 20 20 20 20 20 28 73 65 74 2d 63 64 72 (set-cdr
2200: 21 20 74 77 6f 73 20 74 77 6f 73 29 0a 20 20 20 ! twos twos).
2210: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2220: 28 6c 69 73 74 20 6f 6e 65 73 20 74 77 6f 73 29 (list ones twos)
2230: 29 29 29 29 0a 0a 3b 3b 20 77 69 74 68 6f 75 74 ))))..;; without
2240: 20 73 68 61 72 65 64 20 64 65 74 65 63 74 69 6f shared detectio
2250: 6e 0a 0a 28 74 65 73 74 20 22 28 31 20 31 20 31 n..(test "(1 1 1
2260: 20 31 20 31 22 0a 20 20 20 20 28 66 6d 74 20 23 1 1". (fmt #
2270: 66 20 28 74 72 69 6d 2f 6c 65 6e 67 74 68 0a 20 f (trim/length.
2280: 20 20 20 20 20 20 20 20 20 20 20 20 31 30 0a 20 10.
2290: 20 20 20 20 20 20 20 20 20 20 20 20 28 77 72 74 (wrt
22a0: 2f 75 6e 73 68 61 72 65 64 0a 20 20 20 20 20 20 /unshared.
22b0: 20 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 6f (let ((o
22c0: 6e 65 73 20 28 6c 69 73 74 20 31 29 29 29 20 28 nes (list 1))) (
22d0: 73 65 74 2d 63 64 72 21 20 6f 6e 65 73 20 6f 6e set-cdr! ones on
22e0: 65 73 29 20 6f 6e 65 73 29 29 29 29 29 0a 0a 28 es) ones)))))..(
22f0: 74 65 73 74 20 22 28 31 20 31 20 31 20 31 20 31 test "(1 1 1 1 1
2300: 20 22 0a 20 20 20 20 28 66 6d 74 20 23 66 20 28 ". (fmt #f (
2310: 74 72 69 6d 2f 6c 65 6e 67 74 68 0a 20 20 20 20 trim/length.
2320: 20 20 20 20 20 20 20 20 20 31 31 0a 20 20 20 20 11.
2330: 20 20 20 20 20 20 20 20 20 28 77 72 74 2f 75 6e (wrt/un
2340: 73 68 61 72 65 64 0a 20 20 20 20 20 20 20 20 20 shared.
2350: 20 20 20 20 20 28 6c 65 74 20 28 28 6f 6e 65 73 (let ((ones
2360: 20 28 6c 69 73 74 20 31 29 29 29 20 28 73 65 74 (list 1))) (set
2370: 2d 63 64 72 21 20 6f 6e 65 73 20 6f 6e 65 73 29 -cdr! ones ones)
2380: 20 6f 6e 65 73 29 29 29 29 29 0a 0a 3b 3b 20 70 ones)))))..;; p
2390: 72 65 74 74 79 20 70 72 69 6e 74 69 6e 67 0a 0a retty printing..
23a0: 3b 3b 20 28 64 65 66 69 6e 65 2d 6d 61 63 72 6f ;; (define-macro
23b0: 20 28 74 65 73 74 2d 70 72 65 74 74 79 20 73 74 (test-pretty st
23c0: 72 29 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 73 r).;; (let ((s
23d0: 65 78 70 20 28 77 69 74 68 2d 69 6e 70 75 74 2d exp (with-input-
23e0: 66 72 6f 6d 2d 73 74 72 69 6e 67 20 73 74 72 20 from-string str
23f0: 72 65 61 64 29 29 29 0a 3b 3b 20 20 20 20 20 60 read))).;; `
2400: 28 74 65 73 74 20 2c 73 74 72 20 28 66 6d 74 20 (test ,str (fmt
2410: 23 66 20 28 70 72 65 74 74 79 20 27 2c 73 65 78 #f (pretty ',sex
2420: 70 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 2d p)))))..(define-
2430: 73 79 6e 74 61 78 20 74 65 73 74 2d 70 72 65 74 syntax test-pret
2440: 74 79 0a 20 20 28 73 79 6e 74 61 78 2d 72 75 6c ty. (syntax-rul
2450: 65 73 20 28 29 0a 20 20 20 20 28 28 74 65 73 74 es (). ((test
2460: 2d 70 72 65 74 74 79 20 73 74 72 29 0a 20 20 20 -pretty str).
2470: 20 20 28 6c 65 74 20 28 28 73 65 78 70 20 28 77 (let ((sexp (w
2480: 69 74 68 2d 69 6e 70 75 74 2d 66 72 6f 6d 2d 73 ith-input-from-s
2490: 74 72 69 6e 67 20 73 74 72 20 72 65 61 64 29 29 tring str read))
24a0: 29 0a 20 20 20 20 20 20 20 28 74 65 73 74 20 73 ). (test s
24b0: 74 72 20 28 66 6d 74 20 23 66 20 28 70 72 65 74 tr (fmt #f (pret
24c0: 74 79 20 73 65 78 70 29 29 29 29 29 29 29 0a 0a ty sexp)))))))..
24d0: 28 74 65 73 74 2d 70 72 65 74 74 79 20 22 28 66 (test-pretty "(f
24e0: 6f 6f 20 62 61 72 29 5c 6e 22 29 0a 0a 28 74 65 oo bar)\n")..(te
24f0: 73 74 2d 70 72 65 74 74 79 0a 22 28 28 73 65 6c st-pretty."((sel
2500: 66 20 2e 20 61 71 75 61 6e 65 74 2d 70 61 70 65 f . aquanet-pape
2510: 72 2d 31 39 39 31 29 0a 20 28 74 79 70 65 20 2e r-1991). (type .
2520: 20 70 61 70 65 72 29 0a 20 28 74 69 74 6c 65 20 paper). (title
2530: 2e 20 5c 22 41 71 75 61 6e 65 74 3a 20 61 20 68 . \"Aquanet: a h
2540: 79 70 65 72 74 65 78 74 20 74 6f 6f 6c 20 74 6f ypertext tool to
2550: 20 68 6f 6c 64 20 79 6f 75 72 5c 22 29 29 0a 22 hold your\"))."
2560: 29 0a 0a 28 74 65 73 74 2d 70 72 65 74 74 79 0a )..(test-pretty.
2570: 22 28 61 62 72 61 63 61 64 61 62 72 61 20 78 79 "(abracadabra xy
2580: 6c 6f 70 68 6f 6e 65 0a 20 20 20 20 20 20 20 20 lophone.
2590: 20 20 20 20 20 62 61 6e 61 6e 61 72 61 6d 61 0a bananarama.
25a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 79 65 6c yel
25b0: 6c 6f 77 73 74 6f 6e 65 70 61 72 6b 0a 20 20 20 lowstonepark.
25c0: 20 20 20 20 20 20 20 20 20 20 63 72 79 70 74 6f crypto
25d0: 61 6e 61 6c 79 73 69 73 0a 20 20 20 20 20 20 20 analysis.
25e0: 20 20 20 20 20 20 7a 65 62 72 61 6d 61 6e 69 61 zebramania
25f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 . de
2600: 6c 69 67 68 74 66 75 6c 0a 20 20 20 20 20 20 20 lightful.
2610: 20 20 20 20 20 20 77 75 62 62 6c 65 66 6c 75 62 wubbleflub
2620: 62 65 72 79 29 5c 6e 22 29 0a 0a 28 74 65 73 74 bery)\n")..(test
2630: 2d 70 72 65 74 74 79 0a 20 22 23 28 30 20 20 31 -pretty. "#(0 1
2640: 20 20 32 20 20 33 20 20 34 20 20 35 20 20 36 20 2 3 4 5 6
2650: 20 37 20 20 38 20 20 39 20 20 31 30 20 31 31 20 7 8 9 10 11
2660: 31 32 20 31 33 20 31 34 20 31 35 20 31 36 20 31 12 13 14 15 16 1
2670: 37 20 31 38 20 31 39 20 32 30 20 32 31 20 32 32 7 18 19 20 21 22
2680: 20 32 33 20 32 34 0a 20 20 20 32 35 20 32 36 20 23 24. 25 26
2690: 32 37 20 32 38 20 32 39 20 33 30 20 33 31 20 33 27 28 29 30 31 3
26a0: 32 20 33 33 20 33 34 20 33 35 20 33 36 20 33 37 2 33 34 35 36 37
26b0: 29 5c 6e 22 29 0a 0a 28 74 65 73 74 2d 70 72 65 )\n")..(test-pre
26c0: 74 74 79 0a 20 22 28 30 20 20 31 20 20 32 20 20 tty. "(0 1 2
26d0: 33 20 20 34 20 20 35 20 20 36 20 20 37 20 20 38 3 4 5 6 7 8
26e0: 20 20 39 20 20 31 30 20 31 31 20 31 32 20 31 33 9 10 11 12 13
26f0: 20 31 34 20 31 35 20 31 36 20 31 37 20 31 38 20 14 15 16 17 18
2700: 31 39 20 32 30 20 32 31 20 32 32 20 32 33 20 32 19 20 21 22 23 2
2710: 34 0a 20 20 32 35 20 32 36 20 32 37 20 32 38 20 4. 25 26 27 28
2720: 32 39 20 33 30 20 33 31 20 33 32 20 33 33 20 33 29 30 31 32 33 3
2730: 34 20 33 35 20 33 36 20 33 37 29 5c 6e 22 29 0a 4 35 36 37)\n").
2740: 0a 28 74 65 73 74 2d 70 72 65 74 74 79 0a 20 22 .(test-pretty. "
2750: 28 64 65 66 69 6e 65 20 28 66 6f 6c 64 20 6b 6f (define (fold ko
2760: 6e 73 20 6b 6e 69 6c 20 6c 73 29 0a 20 20 28 64 ns knil ls). (d
2770: 65 66 69 6e 65 20 28 6c 6f 6f 70 20 6c 73 20 61 efine (loop ls a
2780: 63 63 29 0a 20 20 20 20 28 69 66 20 28 6e 75 6c cc). (if (nul
2790: 6c 3f 20 6c 73 29 20 61 63 63 20 28 6c 6f 6f 70 l? ls) acc (loop
27a0: 20 28 63 64 72 20 6c 73 29 20 28 6b 6f 6e 73 20 (cdr ls) (kons
27b0: 28 63 61 72 20 6c 73 29 20 61 63 63 29 29 29 29 (car ls) acc))))
27c0: 0a 20 20 28 6c 6f 6f 70 20 6c 73 20 6b 6e 69 6c . (loop ls knil
27d0: 29 29 5c 6e 22 29 0a 0a 28 74 65 73 74 2d 70 72 ))\n")..(test-pr
27e0: 65 74 74 79 0a 22 28 64 6f 20 28 28 76 65 63 20 etty."(do ((vec
27f0: 28 6d 61 6b 65 2d 76 65 63 74 6f 72 20 35 29 29 (make-vector 5))
2800: 20 28 69 20 30 20 28 2b 20 69 20 31 29 29 29 20 (i 0 (+ i 1)))
2810: 28 28 3d 20 69 20 35 29 20 76 65 63 29 20 28 76 ((= i 5) vec) (v
2820: 65 63 74 6f 72 2d 73 65 74 21 20 76 65 63 20 69 ector-set! vec i
2830: 20 69 29 29 5c 6e 22 29 0a 0a 28 74 65 73 74 2d i))\n")..(test-
2840: 70 72 65 74 74 79 0a 22 28 64 6f 20 28 28 76 65 pretty."(do ((ve
2850: 63 20 28 6d 61 6b 65 2d 76 65 63 74 6f 72 20 35 c (make-vector 5
2860: 29 29 20 28 69 20 30 20 28 2b 20 69 20 31 29 29 )) (i 0 (+ i 1))
2870: 29 20 28 28 3d 20 69 20 35 29 20 76 65 63 29 0a ) ((= i 5) vec).
2880: 20 20 28 76 65 63 74 6f 72 2d 73 65 74 21 20 76 (vector-set! v
2890: 65 63 20 69 20 27 73 75 70 65 72 63 61 6c 69 66 ec i 'supercalif
28a0: 72 61 6a 61 6c 69 73 74 69 63 65 78 70 69 61 6c rajalisticexpial
28b0: 69 64 6f 63 69 6f 75 73 29 29 5c 6e 22 29 0a 0a idocious))\n")..
28c0: 28 74 65 73 74 2d 70 72 65 74 74 79 0a 22 28 64 (test-pretty."(d
28d0: 6f 20 28 28 6d 79 2d 76 65 63 74 6f 72 20 28 6d o ((my-vector (m
28e0: 61 6b 65 2d 76 65 63 74 6f 72 20 35 29 29 20 28 ake-vector 5)) (
28f0: 69 6e 64 65 78 20 30 20 28 2b 20 69 6e 64 65 78 index 0 (+ index
2900: 20 31 29 29 29 0a 20 20 20 20 28 28 3d 20 69 6e 1))). ((= in
2910: 64 65 78 20 35 29 20 6d 79 2d 76 65 63 74 6f 72 dex 5) my-vector
2920: 29 0a 20 20 28 76 65 63 74 6f 72 2d 73 65 74 21 ). (vector-set!
2930: 20 6d 79 2d 76 65 63 74 6f 72 20 69 6e 64 65 78 my-vector index
2940: 20 69 6e 64 65 78 29 29 5c 6e 22 29 0a 0a 28 74 index))\n")..(t
2950: 65 73 74 2d 70 72 65 74 74 79 0a 20 22 28 64 65 est-pretty. "(de
2960: 66 69 6e 65 20 28 66 6f 6c 64 20 6b 6f 6e 73 20 fine (fold kons
2970: 6b 6e 69 6c 20 6c 73 29 0a 20 20 28 6c 65 74 20 knil ls). (let
2980: 6c 6f 6f 70 20 28 28 6c 73 20 6c 73 29 20 28 61 loop ((ls ls) (a
2990: 63 63 20 6b 6e 69 6c 29 29 0a 20 20 20 20 28 69 cc knil)). (i
29a0: 66 20 28 6e 75 6c 6c 3f 20 6c 73 29 20 61 63 63 f (null? ls) acc
29b0: 20 28 6c 6f 6f 70 20 28 63 64 72 20 6c 73 29 20 (loop (cdr ls)
29c0: 28 6b 6f 6e 73 20 28 63 61 72 20 6c 73 29 20 61 (kons (car ls) a
29d0: 63 63 29 29 29 29 29 5c 6e 22 29 0a 0a 28 74 65 cc)))))\n")..(te
29e0: 73 74 2d 70 72 65 74 74 79 0a 20 22 28 64 65 66 st-pretty. "(def
29f0: 69 6e 65 20 28 66 69 6c 65 2d 3e 73 65 78 70 2d ine (file->sexp-
2a00: 6c 69 73 74 20 70 61 74 68 6e 61 6d 65 29 0a 20 list pathname).
2a10: 20 28 63 61 6c 6c 2d 77 69 74 68 2d 69 6e 70 75 (call-with-inpu
2a20: 74 2d 66 69 6c 65 20 70 61 74 68 6e 61 6d 65 0a t-file pathname.
2a30: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 70 6f 72 (lambda (por
2a40: 74 29 0a 20 20 20 20 20 20 28 6c 65 74 20 6c 6f t). (let lo
2a50: 6f 70 20 28 28 72 65 73 20 27 28 29 29 29 0a 20 op ((res '())).
2a60: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 6c 69 (let ((li
2a70: 6e 65 20 28 72 65 61 64 20 70 6f 72 74 29 29 29 ne (read port)))
2a80: 0a 20 20 20 20 20 20 20 20 20 20 28 69 66 20 28 . (if (
2a90: 65 6f 66 2d 6f 62 6a 65 63 74 3f 20 6c 69 6e 65 eof-object? line
2aa0: 29 20 28 72 65 76 65 72 73 65 20 72 65 73 29 20 ) (reverse res)
2ab0: 28 6c 6f 6f 70 20 28 63 6f 6e 73 20 6c 69 6e 65 (loop (cons line
2ac0: 20 72 65 73 29 29 29 29 29 29 29 29 5c 6e 22 29 res))))))))\n")
2ad0: 0a 0a 28 74 65 73 74 20 22 28 6c 65 74 20 28 28 ..(test "(let ((
2ae0: 6f 6e 65 73 20 27 23 30 3d 28 31 20 2e 20 23 30 ones '#0=(1 . #0
2af0: 23 29 29 29 20 6f 6e 65 73 29 5c 6e 22 0a 20 20 #))) ones)\n".
2b00: 20 20 28 66 6d 74 20 23 66 20 28 70 72 65 74 74 (fmt #f (prett
2b10: 79 20 28 6c 65 74 20 28 28 6f 6e 65 73 20 28 6c y (let ((ones (l
2b20: 69 73 74 20 31 29 29 29 20 28 73 65 74 2d 63 64 ist 1))) (set-cd
2b30: 72 21 20 6f 6e 65 73 20 6f 6e 65 73 29 20 60 28 r! ones ones) `(
2b40: 6c 65 74 20 28 28 6f 6e 65 73 20 27 2c 6f 6e 65 let ((ones ',one
2b50: 73 29 29 20 6f 6e 65 73 29 29 29 29 29 0a 0a 27 s)) ones)))))..'
2b60: 28 74 65 73 74 0a 22 28 6c 65 74 20 28 28 7a 65 (test."(let ((ze
2b70: 72 6f 73 20 27 28 30 20 30 20 30 20 30 20 30 20 ros '(0 0 0 0 0
2b80: 30 20 30 20 30 20 30 20 30 20 30 20 30 20 30 20 0 0 0 0 0 0 0 0
2b90: 30 20 30 20 30 20 30 20 30 20 30 20 30 20 30 20 0 0 0 0 0 0 0 0
2ba0: 30 20 30 29 29 0a 20 20 20 20 20 20 28 6f 6e 65 0 0)). (one
2bb0: 73 20 27 23 30 3d 28 31 20 2e 20 23 30 23 29 29 s '#0=(1 . #0#))
2bc0: 29 0a 20 20 28 61 70 70 65 6e 64 20 7a 65 72 6f ). (append zero
2bd0: 73 20 6f 6e 65 73 29 29 5c 6e 22 0a 20 20 20 20 s ones))\n".
2be0: 28 66 6d 74 20 23 66 20 28 70 72 65 74 74 79 0a (fmt #f (pretty.
2bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 65 (le
2c00: 74 20 28 28 6f 6e 65 73 20 28 6c 69 73 74 20 31 t ((ones (list 1
2c10: 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 ))).
2c20: 20 20 20 28 73 65 74 2d 63 64 72 21 20 6f 6e 65 (set-cdr! one
2c30: 73 20 6f 6e 65 73 29 0a 20 20 20 20 20 20 20 20 s ones).
2c40: 20 20 20 20 20 20 20 60 28 6c 65 74 20 28 28 7a `(let ((z
2c50: 65 72 6f 73 20 27 28 30 20 30 20 30 20 30 20 30 eros '(0 0 0 0 0
2c60: 20 30 20 30 20 30 20 30 20 30 20 30 20 30 20 30 0 0 0 0 0 0 0 0
2c70: 20 30 20 30 20 30 20 30 20 30 20 30 20 30 20 30 0 0 0 0 0 0 0 0
2c80: 20 30 20 30 29 29 0a 20 20 20 20 20 20 20 20 20 0 0)).
2c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6f 6e (on
2ca0: 65 73 20 27 2c 6f 6e 65 73 29 29 0a 20 20 20 20 es ',ones)).
2cb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 61 (a
2cc0: 70 70 65 6e 64 20 7a 65 72 6f 73 20 6f 6e 65 73 ppend zeros ones
2cd0: 29 29 29 29 29 29 0a 0a 3b 3b 20 73 6c 61 73 68 ))))))..;; slash
2ce0: 69 66 79 0a 0a 28 74 65 73 74 20 22 5c 22 6e 6f ify..(test "\"no
2cf0: 74 65 5c 22 2c 5c 22 76 65 72 79 20 73 69 6d 70 te\",\"very simp
2d00: 6c 65 5c 22 2c 5c 22 63 73 76 5c 22 2c 5c 22 77 le\",\"csv\",\"w
2d10: 72 69 74 65 72 5c 22 2c 5c 22 5c 22 5c 22 79 61 riter\",\"\"\"ya
2d20: 79 21 5c 22 5c 22 5c 22 22 0a 20 20 20 20 28 66 y!\"\"\"". (f
2d30: 6d 74 20 23 66 20 28 66 6d 74 2d 6a 6f 69 6e 20 mt #f (fmt-join
2d40: 28 6c 61 6d 62 64 61 20 28 78 29 20 28 63 61 74 (lambda (x) (cat
2d50: 20 22 5c 22 22 20 28 73 6c 61 73 68 69 66 69 65 "\"" (slashifie
2d60: 64 20 78 20 23 5c 22 20 23 66 29 20 22 5c 22 22 d x #\" #f) "\""
2d70: 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )).
2d80: 20 20 20 20 20 27 28 22 6e 6f 74 65 22 20 22 76 '("note" "v
2d90: 65 72 79 20 73 69 6d 70 6c 65 22 20 22 63 73 76 ery simple" "csv
2da0: 22 20 22 77 72 69 74 65 72 22 20 22 5c 22 79 61 " "writer" "\"ya
2db0: 79 21 5c 22 22 29 0a 20 20 20 20 20 20 20 20 20 y!\"").
2dc0: 20 20 20 20 20 20 20 20 20 22 2c 22 29 29 29 0a ","))).
2dd0: 0a 28 74 65 73 74 20 22 6e 6f 74 65 2c 5c 22 76 .(test "note,\"v
2de0: 65 72 79 20 73 69 6d 70 6c 65 5c 22 2c 63 73 76 ery simple\",csv
2df0: 2c 77 72 69 74 65 72 2c 5c 22 5c 22 5c 22 79 61 ,writer,\"\"\"ya
2e00: 79 21 5c 22 5c 22 5c 22 22 0a 20 20 20 20 28 66 y!\"\"\"". (f
2e10: 6d 74 20 23 66 20 28 66 6d 74 2d 6a 6f 69 6e 20 mt #f (fmt-join
2e20: 28 63 75 74 20 6d 61 79 62 65 2d 73 6c 61 73 68 (cut maybe-slash
2e30: 69 66 69 65 64 20 3c 3e 20 63 68 61 72 2d 77 68 ified <> char-wh
2e40: 69 74 65 73 70 61 63 65 3f 20 23 5c 22 20 23 66 itespace? #\" #f
2e50: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ).
2e60: 20 20 20 20 27 28 22 6e 6f 74 65 22 20 22 76 65 '("note" "ve
2e70: 72 79 20 73 69 6d 70 6c 65 22 20 22 63 73 76 22 ry simple" "csv"
2e80: 20 22 77 72 69 74 65 72 22 20 22 5c 22 79 61 79 "writer" "\"yay
2e90: 21 5c 22 22 29 0a 20 20 20 20 20 20 20 20 20 20 !\"").
2ea0: 20 20 20 20 20 20 20 20 22 2c 22 29 29 29 0a 0a ",")))..
2eb0: 3b 3b 20 63 6f 6c 75 6d 6e 61 72 20 66 6f 72 6d ;; columnar form
2ec0: 61 74 74 69 6e 67 0a 0a 28 74 65 73 74 20 22 61 atting..(test "a
2ed0: 62 63 5c 6e 64 65 66 5c 6e 22 20 28 66 6d 74 20 bc\ndef\n" (fmt
2ee0: 23 66 20 28 66 6d 74 2d 63 6f 6c 75 6d 6e 73 20 #f (fmt-columns
2ef0: 28 6c 69 73 74 20 64 73 70 20 22 61 62 63 5c 6e (list dsp "abc\n
2f00: 64 65 66 5c 6e 22 29 29 29 29 0a 28 74 65 73 74 def\n")))).(test
2f10: 20 22 61 62 63 31 32 33 5c 6e 64 65 66 34 35 36 "abc123\ndef456
2f20: 5c 6e 22 20 28 66 6d 74 20 23 66 20 28 66 6d 74 \n" (fmt #f (fmt
2f30: 2d 63 6f 6c 75 6d 6e 73 20 28 6c 69 73 74 20 64 -columns (list d
2f40: 73 70 20 22 61 62 63 5c 6e 64 65 66 5c 6e 22 29 sp "abc\ndef\n")
2f50: 20 28 6c 69 73 74 20 64 73 70 20 22 31 32 33 5c (list dsp "123\
2f60: 6e 34 35 36 5c 6e 22 29 29 29 29 0a 28 74 65 73 n456\n")))).(tes
2f70: 74 20 22 61 62 63 31 32 33 5c 6e 64 65 66 34 35 t "abc123\ndef45
2f80: 36 5c 6e 22 20 28 66 6d 74 20 23 66 20 28 66 6d 6\n" (fmt #f (fm
2f90: 74 2d 63 6f 6c 75 6d 6e 73 20 28 6c 69 73 74 20 t-columns (list
2fa0: 64 73 70 20 22 61 62 63 5c 6e 64 65 66 5c 6e 22 dsp "abc\ndef\n"
2fb0: 29 20 28 6c 69 73 74 20 64 73 70 20 22 31 32 33 ) (list dsp "123
2fc0: 5c 6e 34 35 36 22 29 29 29 29 0a 28 74 65 73 74 \n456")))).(test
2fd0: 20 22 61 62 63 31 32 33 5c 6e 64 65 66 34 35 36 "abc123\ndef456
2fe0: 5c 6e 22 20 28 66 6d 74 20 23 66 20 28 66 6d 74 \n" (fmt #f (fmt
2ff0: 2d 63 6f 6c 75 6d 6e 73 20 28 6c 69 73 74 20 64 -columns (list d
3000: 73 70 20 22 61 62 63 5c 6e 64 65 66 22 29 20 28 sp "abc\ndef") (
3010: 6c 69 73 74 20 64 73 70 20 22 31 32 33 5c 6e 34 list dsp "123\n4
3020: 35 36 5c 6e 22 29 29 29 29 0a 28 74 65 73 74 20 56\n")))).(test
3030: 22 61 62 63 31 32 33 5c 6e 64 65 66 34 35 36 5c "abc123\ndef456\
3040: 6e 67 68 69 37 38 39 5c 6e 22 0a 20 20 20 20 28 nghi789\n". (
3050: 66 6d 74 20 23 66 20 28 66 6d 74 2d 63 6f 6c 75 fmt #f (fmt-colu
3060: 6d 6e 73 20 28 6c 69 73 74 20 64 73 70 20 22 61 mns (list dsp "a
3070: 62 63 5c 6e 64 65 66 5c 6e 67 68 69 5c 6e 22 29 bc\ndef\nghi\n")
3080: 20 28 6c 69 73 74 20 64 73 70 20 22 31 32 33 5c (list dsp "123\
3090: 6e 34 35 36 5c 6e 37 38 39 5c 6e 22 29 29 29 29 n456\n789\n"))))
30a0: 0a 28 74 65 73 74 20 22 61 62 63 31 32 33 77 75 .(test "abc123wu
30b0: 76 5c 6e 64 65 66 34 35 36 78 79 7a 5c 6e 22 0a v\ndef456xyz\n".
30c0: 20 20 20 20 28 66 6d 74 20 23 66 20 28 66 6d 74 (fmt #f (fmt
30d0: 2d 63 6f 6c 75 6d 6e 73 20 28 6c 69 73 74 20 64 -columns (list d
30e0: 73 70 20 22 61 62 63 5c 6e 64 65 66 5c 6e 22 29 sp "abc\ndef\n")
30f0: 20 28 6c 69 73 74 20 64 73 70 20 22 31 32 33 5c (list dsp "123\
3100: 6e 34 35 36 5c 6e 22 29 20 28 6c 69 73 74 20 64 n456\n") (list d
3110: 73 70 20 22 77 75 76 5c 6e 78 79 7a 5c 6e 22 29 sp "wuv\nxyz\n")
3120: 29 29 29 0a 28 74 65 73 74 20 22 61 62 63 20 20 ))).(test "abc
3130: 31 32 33 5c 6e 64 65 66 20 20 34 35 36 5c 6e 22 123\ndef 456\n"
3140: 0a 20 20 20 20 28 66 6d 74 20 23 66 20 28 66 6d . (fmt #f (fm
3150: 74 2d 63 6f 6c 75 6d 6e 73 20 28 6c 69 73 74 20 t-columns (list
3160: 28 63 75 74 20 70 61 64 2f 72 69 67 68 74 20 35 (cut pad/right 5
3170: 20 3c 3e 29 20 22 61 62 63 5c 6e 64 65 66 5c 6e <>) "abc\ndef\n
3180: 22 29 20 28 6c 69 73 74 20 64 73 70 20 22 31 32 ") (list dsp "12
3190: 33 5c 6e 34 35 36 5c 6e 22 29 29 29 29 0a 28 74 3\n456\n")))).(t
31a0: 65 73 74 20 22 41 42 43 20 20 31 32 33 5c 6e 44 est "ABC 123\nD
31b0: 45 46 20 20 34 35 36 5c 6e 22 0a 20 20 20 20 28 EF 456\n". (
31c0: 66 6d 74 20 23 66 20 28 66 6d 74 2d 63 6f 6c 75 fmt #f (fmt-colu
31d0: 6d 6e 73 20 28 6c 69 73 74 20 28 63 6f 6d 70 6f mns (list (compo
31e0: 73 65 20 75 70 63 61 73 65 20 28 63 75 74 20 70 se upcase (cut p
31f0: 61 64 2f 72 69 67 68 74 20 35 20 3c 3e 29 29 20 ad/right 5 <>))
3200: 22 61 62 63 5c 6e 64 65 66 5c 6e 22 29 0a 20 20 "abc\ndef\n").
3210: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3220: 20 20 20 20 20 20 20 28 6c 69 73 74 20 64 73 70 (list dsp
3230: 20 22 31 32 33 5c 6e 34 35 36 5c 6e 22 29 29 29 "123\n456\n")))
3240: 29 0a 28 74 65 73 74 20 22 41 42 43 20 20 31 32 ).(test "ABC 12
3250: 33 5c 6e 44 45 46 20 20 34 35 36 5c 6e 22 0a 20 3\nDEF 456\n".
3260: 20 20 20 28 66 6d 74 20 23 66 20 28 66 6d 74 2d (fmt #f (fmt-
3270: 63 6f 6c 75 6d 6e 73 20 28 6c 69 73 74 20 28 63 columns (list (c
3280: 6f 6d 70 6f 73 65 20 28 63 75 74 20 70 61 64 2f ompose (cut pad/
3290: 72 69 67 68 74 20 35 20 3c 3e 29 20 75 70 63 61 right 5 <>) upca
32a0: 73 65 29 20 22 61 62 63 5c 6e 64 65 66 5c 6e 22 se) "abc\ndef\n"
32b0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ).
32c0: 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73 74 (list
32d0: 20 64 73 70 20 22 31 32 33 5c 6e 34 35 36 5c 6e dsp "123\n456\n
32e0: 22 29 29 29 29 0a 0a 28 74 65 73 74 20 22 68 65 "))))..(test "he
32f0: 6c 6c 6f 5c 6e 77 6f 72 6c 64 5c 6e 22 20 28 66 llo\nworld\n" (f
3300: 6d 74 20 23 66 20 28 77 69 74 68 2d 77 69 64 74 mt #f (with-widt
3310: 68 20 38 20 28 77 72 61 70 2d 6c 69 6e 65 73 20 h 8 (wrap-lines
3320: 22 68 65 6c 6c 6f 20 77 6f 72 6c 64 22 29 29 29 "hello world")))
3330: 29 0a 28 74 65 73 74 20 22 5c 6e 22 20 28 66 6d ).(test "\n" (fm
3340: 74 20 23 66 20 28 77 72 61 70 2d 6c 69 6e 65 73 t #f (wrap-lines
3350: 20 22 20 20 20 20 22 29 29 29 0a 0a 28 74 65 73 " ")))..(tes
3360: 74 20 20 20 20 20 20 20 20 20 20 3b 3b 20 74 65 t ;; te
3370: 73 74 20 64 69 76 69 64 65 20 62 79 20 7a 65 72 st divide by zer
3380: 6f 20 65 72 72 6f 72 0a 20 22 54 68 65 20 20 71 o error. "The q
3390: 75 69 63 6b 0a 62 72 6f 77 6e 20 20 66 6f 78 0a uick.brown fox.
33a0: 6a 75 6d 70 65 64 0a 6f 76 65 72 20 20 20 74 68 jumped.over th
33b0: 65 0a 6c 61 7a 79 20 64 6f 67 0a 22 0a 20 28 66 e.lazy dog.". (f
33c0: 6d 74 20 23 66 20 28 77 69 74 68 2d 77 69 64 74 mt #f (with-widt
33d0: 68 20 31 30 20 28 6a 75 73 74 69 66 79 20 22 54 h 10 (justify "T
33e0: 68 65 20 71 75 69 63 6b 20 62 72 6f 77 6e 20 66 he quick brown f
33f0: 6f 78 20 6a 75 6d 70 65 64 20 6f 76 65 72 20 74 ox jumped over t
3400: 68 65 20 6c 61 7a 79 20 64 6f 67 22 29 29 29 29 he lazy dog"))))
3410: 0a 0a 28 74 65 73 74 20 22 68 69 73 20 6d 65 73 ..(test "his mes
3420: 73 61 67 65 0a 28 68 74 74 70 3a 2f 2f 6c 69 73 sage.(http://lis
3430: 74 73 2e 6e 6f 6e 67 6e 75 2e 6f 72 67 2f 61 72 ts.nongnu.org/ar
3440: 63 68 69 76 65 2f 68 74 6d 6c 2f 63 68 69 63 6b chive/html/chick
3450: 65 6e 2d 75 73 65 72 73 2f 32 30 31 30 2d 31 30 en-users/2010-10
3460: 2f 6d 73 67 30 30 31 37 31 2e 68 74 6d 6c 29 0a /msg00171.html).
3470: 74 6f 20 74 68 65 20 63 68 69 63 6b 65 6e 2d 75 to the chicken-u
3480: 73 65 72 73 0a 28 68 74 74 70 3a 2f 2f 6c 69 73 sers.(http://lis
3490: 74 73 2e 6e 6f 6e 67 6e 75 2e 6f 72 67 2f 6d 61 ts.nongnu.org/ma
34a0: 69 6c 6d 61 6e 2f 6c 69 73 74 69 6e 66 6f 2f 63 ilman/listinfo/c
34b0: 68 69 63 6b 65 6e 2d 75 73 65 72 73 29 5c 6e 22 hicken-users)\n"
34c0: 0a 20 20 20 20 20 20 28 66 6d 74 20 23 66 20 28 . (fmt #f (
34d0: 77 69 74 68 2d 77 69 64 74 68 20 36 37 20 28 77 with-width 67 (w
34e0: 72 61 70 2d 6c 69 6e 65 73 20 22 68 69 73 20 6d rap-lines "his m
34f0: 65 73 73 61 67 65 20 28 68 74 74 70 3a 2f 2f 6c essage (http://l
3500: 69 73 74 73 2e 6e 6f 6e 67 6e 75 2e 6f 72 67 2f ists.nongnu.org/
3510: 61 72 63 68 69 76 65 2f 68 74 6d 6c 2f 63 68 69 archive/html/chi
3520: 63 6b 65 6e 2d 75 73 65 72 73 2f 32 30 31 30 2d cken-users/2010-
3530: 31 30 2f 6d 73 67 30 30 31 37 31 2e 68 74 6d 6c 10/msg00171.html
3540: 29 20 74 6f 20 74 68 65 20 63 68 69 63 6b 65 6e ) to the chicken
3550: 2d 75 73 65 72 73 20 28 68 74 74 70 3a 2f 2f 6c -users (http://l
3560: 69 73 74 73 2e 6e 6f 6e 67 6e 75 2e 6f 72 67 2f ists.nongnu.org/
3570: 6d 61 69 6c 6d 61 6e 2f 6c 69 73 74 69 6e 66 6f mailman/listinfo
3580: 2f 63 68 69 63 6b 65 6e 2d 75 73 65 72 73 29 22 /chicken-users)"
3590: 29 29 29 29 0a 0a 28 74 65 73 74 20 22 54 68 65 ))))..(test "The
35a0: 20 66 75 6e 64 61 6d 65 6e 74 61 6c 20 6c 69 73 fundamental lis
35b0: 74 20 69 74 65 72 61 74 6f 72 2e 0a 41 70 70 6c t iterator..Appl
35c0: 69 65 73 20 4b 4f 4e 53 20 74 6f 20 65 61 63 68 ies KONS to each
35d0: 20 65 6c 65 6d 65 6e 74 20 6f 66 0a 4c 53 20 61 element of.LS a
35e0: 6e 64 20 74 68 65 20 72 65 73 75 6c 74 20 6f 66 nd the result of
35f0: 20 74 68 65 20 70 72 65 76 69 6f 75 73 0a 61 70 the previous.ap
3600: 70 6c 69 63 61 74 69 6f 6e 2c 20 62 65 67 69 6e plication, begin
3610: 6e 69 6e 67 20 77 69 74 68 20 4b 4e 49 4c 2e 0a ning with KNIL..
3620: 57 69 74 68 20 4b 4f 4e 53 20 61 73 20 43 4f 4e With KONS as CON
3630: 53 20 61 6e 64 20 4b 4e 49 4c 20 61 73 20 27 28 S and KNIL as '(
3640: 29 2c 0a 65 71 75 69 76 61 6c 65 6e 74 20 74 6f ),.equivalent to
3650: 20 52 45 56 45 52 53 45 2e 0a 22 0a 20 20 20 20 REVERSE..".
3660: 28 66 6d 74 20 23 66 20 28 77 69 74 68 2d 77 69 (fmt #f (with-wi
3670: 64 74 68 20 33 36 20 28 77 72 61 70 2d 6c 69 6e dth 36 (wrap-lin
3680: 65 73 20 22 54 68 65 20 66 75 6e 64 61 6d 65 6e es "The fundamen
3690: 74 61 6c 20 6c 69 73 74 20 69 74 65 72 61 74 6f tal list iterato
36a0: 72 2e 20 20 41 70 70 6c 69 65 73 20 4b 4f 4e 53 r. Applies KONS
36b0: 20 74 6f 20 65 61 63 68 20 65 6c 65 6d 65 6e 74 to each element
36c0: 20 6f 66 20 4c 53 20 61 6e 64 20 74 68 65 20 72 of LS and the r
36d0: 65 73 75 6c 74 20 6f 66 20 74 68 65 20 70 72 65 esult of the pre
36e0: 76 69 6f 75 73 20 61 70 70 6c 69 63 61 74 69 6f vious applicatio
36f0: 6e 2c 20 62 65 67 69 6e 6e 69 6e 67 20 77 69 74 n, beginning wit
3700: 68 20 4b 4e 49 4c 2e 20 20 57 69 74 68 20 4b 4f h KNIL. With KO
3710: 4e 53 20 61 73 20 43 4f 4e 53 20 61 6e 64 20 4b NS as CONS and K
3720: 4e 49 4c 20 61 73 20 27 28 29 2c 20 65 71 75 69 NIL as '(), equi
3730: 76 61 6c 65 6e 74 20 74 6f 20 52 45 56 45 52 53 valent to REVERS
3740: 45 2e 22 29 29 29 29 0a 0a 28 74 65 73 74 0a 22 E."))))..(test."
3750: 54 68 65 20 20 20 66 75 6e 64 61 6d 65 6e 74 61 The fundamenta
3760: 6c 20 20 20 6c 69 73 74 20 20 20 69 74 65 72 61 l list itera
3770: 74 6f 72 2e 0a 41 70 70 6c 69 65 73 20 20 4b 4f tor..Applies KO
3780: 4e 53 20 20 74 6f 20 20 65 61 63 68 20 20 65 6c NS to each el
3790: 65 6d 65 6e 74 20 20 6f 66 0a 4c 53 20 20 61 6e ement of.LS an
37a0: 64 20 20 74 68 65 20 20 72 65 73 75 6c 74 20 6f d the result o
37b0: 66 20 74 68 65 20 70 72 65 76 69 6f 75 73 0a 61 f the previous.a
37c0: 70 70 6c 69 63 61 74 69 6f 6e 2c 20 20 62 65 67 pplication, beg
37d0: 69 6e 6e 69 6e 67 20 20 77 69 74 68 20 20 4b 4e inning with KN
37e0: 49 4c 2e 0a 57 69 74 68 20 20 4b 4f 4e 53 20 20 IL..With KONS
37f0: 61 73 20 43 4f 4e 53 20 61 6e 64 20 4b 4e 49 4c as CONS and KNIL
3800: 20 61 73 20 27 28 29 2c 0a 65 71 75 69 76 61 6c as '(),.equival
3810: 65 6e 74 20 74 6f 20 52 45 56 45 52 53 45 2e 0a ent to REVERSE..
3820: 22 0a 20 20 20 20 28 66 6d 74 20 23 66 20 28 77 ". (fmt #f (w
3830: 69 74 68 2d 77 69 64 74 68 20 33 36 20 28 6a 75 ith-width 36 (ju
3840: 73 74 69 66 79 20 22 54 68 65 20 66 75 6e 64 61 stify "The funda
3850: 6d 65 6e 74 61 6c 20 6c 69 73 74 20 69 74 65 72 mental list iter
3860: 61 74 6f 72 2e 20 20 41 70 70 6c 69 65 73 20 4b ator. Applies K
3870: 4f 4e 53 20 74 6f 20 65 61 63 68 20 65 6c 65 6d ONS to each elem
3880: 65 6e 74 20 6f 66 20 4c 53 20 61 6e 64 20 74 68 ent of LS and th
3890: 65 20 72 65 73 75 6c 74 20 6f 66 20 74 68 65 20 e result of the
38a0: 70 72 65 76 69 6f 75 73 20 61 70 70 6c 69 63 61 previous applica
38b0: 74 69 6f 6e 2c 20 62 65 67 69 6e 6e 69 6e 67 20 tion, beginning
38c0: 77 69 74 68 20 4b 4e 49 4c 2e 20 20 57 69 74 68 with KNIL. With
38d0: 20 4b 4f 4e 53 20 61 73 20 43 4f 4e 53 20 61 6e KONS as CONS an
38e0: 64 20 4b 4e 49 4c 20 61 73 20 27 28 29 2c 20 65 d KNIL as '(), e
38f0: 71 75 69 76 61 6c 65 6e 74 20 74 6f 20 52 45 56 quivalent to REV
3900: 45 52 53 45 2e 22 29 29 29 29 0a 0a 28 74 65 73 ERSE."))))..(tes
3910: 74 0a 22 28 64 65 66 69 6e 65 20 28 66 6f 6c 64 t."(define (fold
3920: 20 6b 6f 6e 73 20 6b 6e 69 6c 20 6c 73 29 20 20 kons knil ls)
3930: 20 20 20 20 20 20 20 20 3b 20 54 68 65 20 66 75 ; The fu
3940: 6e 64 61 6d 65 6e 74 61 6c 20 6c 69 73 74 20 69 ndamental list i
3950: 74 65 72 61 74 6f 72 2e 0a 20 20 28 6c 65 74 20 terator.. (let
3960: 6c 70 20 28 28 6c 73 20 6c 73 29 20 28 61 63 63 lp ((ls ls) (acc
3970: 20 6b 6e 69 6c 29 29 20 20 20 20 20 20 20 3b 20 knil)) ;
3980: 41 70 70 6c 69 65 73 20 4b 4f 4e 53 20 74 6f 20 Applies KONS to
3990: 65 61 63 68 20 65 6c 65 6d 65 6e 74 20 6f 66 0a each element of.
39a0: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 6c (if (null? l
39b0: 73 29 20 20 20 20 20 20 20 20 20 20 20 20 20 20 s)
39c0: 20 20 20 20 20 3b 20 4c 53 20 61 6e 64 20 74 68 ; LS and th
39d0: 65 20 72 65 73 75 6c 74 20 6f 66 20 74 68 65 20 e result of the
39e0: 70 72 65 76 69 6f 75 73 0a 20 20 20 20 20 20 20 previous.
39f0: 20 61 63 63 20 20 20 20 20 20 20 20 20 20 20 20 acc
3a00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 ;
3a10: 61 70 70 6c 69 63 61 74 69 6f 6e 2c 20 62 65 67 application, beg
3a20: 69 6e 6e 69 6e 67 20 77 69 74 68 20 4b 4e 49 4c inning with KNIL
3a30: 2e 0a 20 20 20 20 20 20 20 20 28 6c 70 20 28 63 .. (lp (c
3a40: 64 72 20 6c 73 29 20 20 20 20 20 20 20 20 20 20 dr ls)
3a50: 20 20 20 20 20 20 20 3b 20 57 69 74 68 20 4b 4f ; With KO
3a60: 4e 53 20 61 73 20 43 4f 4e 53 20 61 6e 64 20 4b NS as CONS and K
3a70: 4e 49 4c 20 61 73 20 27 28 29 2c 0a 20 20 20 20 NIL as '(),.
3a80: 20 20 20 20 20 20 20 20 28 6b 6f 6e 73 20 28 63 (kons (c
3a90: 61 72 20 6c 73 29 20 61 63 63 29 29 29 29 29 20 ar ls) acc)))))
3aa0: 20 3b 20 65 71 75 69 76 61 6c 65 6e 74 20 74 6f ; equivalent to
3ab0: 20 52 45 56 45 52 53 45 2e 0a 22 0a 20 20 20 20 REVERSE..".
3ac0: 28 66 6d 74 20 23 66 20 28 66 6d 74 2d 63 6f 6c (fmt #f (fmt-col
3ad0: 75 6d 6e 73 0a 20 20 20 20 20 20 20 20 20 20 20 umns.
3ae0: 20 20 28 6c 69 73 74 0a 20 20 20 20 20 20 20 20 (list.
3af0: 20 20 20 20 20 20 28 63 75 74 20 70 61 64 2f 72 (cut pad/r
3b00: 69 67 68 74 20 33 36 20 3c 3e 29 0a 20 20 20 20 ight 36 <>).
3b10: 20 20 20 20 20 20 20 20 20 20 28 77 69 74 68 2d (with-
3b20: 77 69 64 74 68 20 33 36 0a 20 20 20 20 20 20 20 width 36.
3b30: 20 20 20 20 20 20 20 20 20 28 70 72 65 74 74 79 (pretty
3b40: 20 27 28 64 65 66 69 6e 65 20 28 66 6f 6c 64 20 '(define (fold
3b50: 6b 6f 6e 73 20 6b 6e 69 6c 20 6c 73 29 0a 20 20 kons knil ls).
3b60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3b70: 20 20 20 20 20 20 20 20 20 28 6c 65 74 20 6c 70 (let lp
3b80: 20 28 28 6c 73 20 6c 73 29 20 28 61 63 63 20 6b ((ls ls) (acc k
3b90: 6e 69 6c 29 29 0a 20 20 20 20 20 20 20 20 20 20 nil)).
3ba0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3bb0: 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 6c 73 (if (null? ls
3bc0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ).
3bd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3be0: 20 20 20 61 63 63 0a 20 20 20 20 20 20 20 20 20 acc.
3bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3c00: 20 20 20 20 20 20 20 20 28 6c 70 20 28 63 64 72 (lp (cdr
3c10: 20 6c 73 29 0a 20 20 20 20 20 20 20 20 20 20 20 ls).
3c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3c30: 20 20 20 20 20 20 20 20 20 20 28 6b 6f 6e 73 20 (kons
3c40: 28 63 61 72 20 6c 73 29 20 61 63 63 29 29 29 29 (car ls) acc))))
3c50: 29 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 )))).
3c60: 20 20 28 6c 69 73 74 0a 20 20 20 20 20 20 20 20 (list.
3c70: 20 20 20 20 20 20 28 63 75 74 20 63 61 74 20 22 (cut cat "
3c80: 20 3b 20 22 20 3c 3e 29 0a 20 20 20 20 20 20 20 ; " <>).
3c90: 20 20 20 20 20 20 20 28 77 69 74 68 2d 77 69 64 (with-wid
3ca0: 74 68 20 33 36 0a 20 20 20 20 20 20 20 20 20 20 th 36.
3cb0: 20 20 20 20 20 20 28 77 72 61 70 2d 6c 69 6e 65 (wrap-line
3cc0: 73 20 22 54 68 65 20 66 75 6e 64 61 6d 65 6e 74 s "The fundament
3cd0: 61 6c 20 6c 69 73 74 20 69 74 65 72 61 74 6f 72 al list iterator
3ce0: 2e 20 20 41 70 70 6c 69 65 73 20 4b 4f 4e 53 20 . Applies KONS
3cf0: 74 6f 20 65 61 63 68 20 65 6c 65 6d 65 6e 74 20 to each element
3d00: 6f 66 20 4c 53 20 61 6e 64 20 74 68 65 20 72 65 of LS and the re
3d10: 73 75 6c 74 20 6f 66 20 74 68 65 20 70 72 65 76 sult of the prev
3d20: 69 6f 75 73 20 61 70 70 6c 69 63 61 74 69 6f 6e ious application
3d30: 2c 20 62 65 67 69 6e 6e 69 6e 67 20 77 69 74 68 , beginning with
3d40: 20 4b 4e 49 4c 2e 20 20 57 69 74 68 20 4b 4f 4e KNIL. With KON
3d50: 53 20 61 73 20 43 4f 4e 53 20 61 6e 64 20 4b 4e S as CONS and KN
3d60: 49 4c 20 61 73 20 27 28 29 2c 20 65 71 75 69 76 IL as '(), equiv
3d70: 61 6c 65 6e 74 20 74 6f 20 52 45 56 45 52 53 45 alent to REVERSE
3d80: 2e 22 29 29 29 29 29 29 0a 0a 28 74 65 73 74 0a ."))))))..(test.
3d90: 22 28 64 65 66 69 6e 65 20 28 66 6f 6c 64 20 6b "(define (fold k
3da0: 6f 6e 73 20 6b 6e 69 6c 20 6c 73 29 20 20 20 20 ons knil ls)
3db0: 20 20 20 20 20 20 3b 20 54 68 65 20 66 75 6e 64 ; The fund
3dc0: 61 6d 65 6e 74 61 6c 20 6c 69 73 74 20 69 74 65 amental list ite
3dd0: 72 61 74 6f 72 2e 0a 20 20 28 6c 65 74 20 6c 70 rator.. (let lp
3de0: 20 28 28 6c 73 20 6c 73 29 20 28 61 63 63 20 6b ((ls ls) (acc k
3df0: 6e 69 6c 29 29 20 20 20 20 20 20 20 3b 20 41 70 nil)) ; Ap
3e00: 70 6c 69 65 73 20 4b 4f 4e 53 20 74 6f 20 65 61 plies KONS to ea
3e10: 63 68 20 65 6c 65 6d 65 6e 74 20 6f 66 0a 20 20 ch element of.
3e20: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 6c 73 29 (if (null? ls)
3e30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3e40: 20 20 20 3b 20 4c 53 20 61 6e 64 20 74 68 65 20 ; LS and the
3e50: 72 65 73 75 6c 74 20 6f 66 20 74 68 65 20 70 72 result of the pr
3e60: 65 76 69 6f 75 73 0a 20 20 20 20 20 20 20 20 61 evious. a
3e70: 63 63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 cc
3e80: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 61 70 ; ap
3e90: 70 6c 69 63 61 74 69 6f 6e 2c 20 62 65 67 69 6e plication, begin
3ea0: 6e 69 6e 67 20 77 69 74 68 20 4b 4e 49 4c 2e 0a ning with KNIL..
3eb0: 20 20 20 20 20 20 20 20 28 6c 70 20 28 63 64 72 (lp (cdr
3ec0: 20 6c 73 29 20 20 20 20 20 20 20 20 20 20 20 20 ls)
3ed0: 20 20 20 20 20 3b 20 57 69 74 68 20 4b 4f 4e 53 ; With KONS
3ee0: 20 61 73 20 43 4f 4e 53 20 61 6e 64 20 4b 4e 49 as CONS and KNI
3ef0: 4c 20 61 73 20 27 28 29 2c 0a 20 20 20 20 20 20 L as '(),.
3f00: 20 20 20 20 20 20 28 6b 6f 6e 73 20 28 63 61 72 (kons (car
3f10: 20 6c 73 29 20 61 63 63 29 29 29 29 29 20 20 3b ls) acc))))) ;
3f20: 20 65 71 75 69 76 61 6c 65 6e 74 20 74 6f 20 52 equivalent to R
3f30: 45 56 45 52 53 45 2e 0a 22 0a 20 20 20 20 28 66 EVERSE..". (f
3f40: 6d 74 20 23 66 20 28 77 69 74 68 2d 77 69 64 74 mt #f (with-widt
3f50: 68 20 37 36 0a 20 20 20 20 20 20 20 20 20 20 20 h 76.
3f60: 20 20 20 28 63 6f 6c 75 6d 6e 61 72 0a 20 20 20 (columnar.
3f70: 20 20 20 20 20 20 20 20 20 20 20 20 28 70 72 65 (pre
3f80: 74 74 79 20 27 28 64 65 66 69 6e 65 20 28 66 6f tty '(define (fo
3f90: 6c 64 20 6b 6f 6e 73 20 6b 6e 69 6c 20 6c 73 29 ld kons knil ls)
3fa0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
3fb0: 20 20 20 20 20 20 20 20 20 20 20 28 6c 65 74 20 (let
3fc0: 6c 70 20 28 28 6c 73 20 6c 73 29 20 28 61 63 63 lp ((ls ls) (acc
3fd0: 20 6b 6e 69 6c 29 29 0a 20 20 20 20 20 20 20 20 knil)).
3fe0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3ff0: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 6c (if (null? l
4000: 73 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 s).
4010: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4020: 20 20 20 61 63 63 0a 20 20 20 20 20 20 20 20 20 acc.
4030: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4040: 20 20 20 20 20 20 20 28 6c 70 20 28 63 64 72 20 (lp (cdr
4050: 6c 73 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 ls).
4060: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4070: 20 20 20 20 20 20 20 20 28 6b 6f 6e 73 20 28 63 (kons (c
4080: 61 72 20 6c 73 29 20 61 63 63 29 29 29 29 29 29 ar ls) acc))))))
4090: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
40a0: 22 20 3b 20 22 0a 20 20 20 20 20 20 20 20 20 20 " ; ".
40b0: 20 20 20 20 20 28 77 72 61 70 2d 6c 69 6e 65 73 (wrap-lines
40c0: 20 22 54 68 65 20 66 75 6e 64 61 6d 65 6e 74 61 "The fundamenta
40d0: 6c 20 6c 69 73 74 20 69 74 65 72 61 74 6f 72 2e l list iterator.
40e0: 20 20 41 70 70 6c 69 65 73 20 4b 4f 4e 53 20 74 Applies KONS t
40f0: 6f 20 65 61 63 68 20 65 6c 65 6d 65 6e 74 20 6f o each element o
4100: 66 20 4c 53 20 61 6e 64 20 74 68 65 20 72 65 73 f LS and the res
4110: 75 6c 74 20 6f 66 20 74 68 65 20 70 72 65 76 69 ult of the previ
4120: 6f 75 73 20 61 70 70 6c 69 63 61 74 69 6f 6e 2c ous application,
4130: 20 62 65 67 69 6e 6e 69 6e 67 20 77 69 74 68 20 beginning with
4140: 4b 4e 49 4c 2e 20 20 57 69 74 68 20 4b 4f 4e 53 KNIL. With KONS
4150: 20 61 73 20 43 4f 4e 53 20 61 6e 64 20 4b 4e 49 as CONS and KNI
4160: 4c 20 61 73 20 27 28 29 2c 20 65 71 75 69 76 61 L as '(), equiva
4170: 6c 65 6e 74 20 74 6f 20 52 45 56 45 52 53 45 2e lent to REVERSE.
4180: 22 29 29 29 29 29 0a 0a 28 74 65 73 74 0a 22 2d ")))))..(test."-
4190: 20 49 74 65 6d 20 31 3a 20 54 68 65 20 74 65 78 Item 1: The tex
41a0: 74 20 68 65 72 65 20 69 73 0a 20 20 20 20 20 20 t here is.
41b0: 20 20 20 20 69 6e 64 65 6e 74 65 64 20 61 63 63 indented acc
41c0: 6f 72 64 69 6e 67 0a 20 20 20 20 20 20 20 20 20 ording.
41d0: 20 74 6f 20 74 68 65 20 73 70 61 63 65 20 5c 22 to the space \"
41e0: 49 74 65 6d 0a 20 20 20 20 20 20 20 20 20 20 31 Item. 1
41f0: 5c 22 20 74 61 6b 65 73 2c 20 61 6e 64 20 6f 6e \" takes, and on
4200: 65 0a 20 20 20 20 20 20 20 20 20 20 64 6f 65 73 e. does
4210: 20 6e 6f 74 20 6b 6e 6f 77 6e 20 77 68 61 74 0a not known what.
4220: 20 20 20 20 20 20 20 20 20 20 67 6f 65 73 20 68 goes h
4230: 65 72 65 2e 0a 22 0a 20 20 20 20 28 66 6d 74 20 ere..". (fmt
4240: 23 66 20 28 63 6f 6c 75 6d 6e 61 72 20 39 20 28 #f (columnar 9 (
4250: 64 73 70 20 22 2d 20 49 74 65 6d 20 31 3a 22 29 dsp "- Item 1:")
4260: 20 22 20 22 20 28 77 69 74 68 2d 77 69 64 74 68 " " (with-width
4270: 20 32 30 20 28 77 72 61 70 2d 6c 69 6e 65 73 20 20 (wrap-lines
4280: 22 54 68 65 20 74 65 78 74 20 68 65 72 65 20 69 "The text here i
4290: 73 20 69 6e 64 65 6e 74 65 64 20 61 63 63 6f 72 s indented accor
42a0: 64 69 6e 67 20 74 6f 20 74 68 65 20 73 70 61 63 ding to the spac
42b0: 65 20 5c 22 49 74 65 6d 20 31 5c 22 20 74 61 6b e \"Item 1\" tak
42c0: 65 73 2c 20 61 6e 64 20 6f 6e 65 20 64 6f 65 73 es, and one does
42d0: 20 6e 6f 74 20 6b 6e 6f 77 6e 20 77 68 61 74 20 not known what
42e0: 67 6f 65 73 20 68 65 72 65 2e 22 29 29 29 29 29 goes here.")))))
42f0: 0a 0a 28 74 65 73 74 0a 22 2d 20 49 74 65 6d 20 ..(test."- Item
4300: 31 3a 20 54 68 65 20 74 65 78 74 20 68 65 72 65 1: The text here
4310: 20 69 73 0a 20 20 20 20 20 20 20 20 20 20 69 6e is. in
4320: 64 65 6e 74 65 64 20 61 63 63 6f 72 64 69 6e 67 dented according
4330: 0a 20 20 20 20 20 20 20 20 20 20 74 6f 20 74 68 . to th
4340: 65 20 73 70 61 63 65 20 5c 22 49 74 65 6d 0a 20 e space \"Item.
4350: 20 20 20 20 20 20 20 20 20 31 5c 22 20 74 61 6b 1\" tak
4360: 65 73 2c 20 61 6e 64 20 6f 6e 65 0a 20 20 20 20 es, and one.
4370: 20 20 20 20 20 20 64 6f 65 73 20 6e 6f 74 20 6b does not k
4380: 6e 6f 77 6e 20 77 68 61 74 0a 20 20 20 20 20 20 nown what.
4390: 20 20 20 20 67 6f 65 73 20 68 65 72 65 2e 0a 22 goes here.."
43a0: 0a 20 20 20 20 28 66 6d 74 20 23 66 20 28 63 6f . (fmt #f (co
43b0: 6c 75 6d 6e 61 72 20 39 20 28 64 73 70 20 22 2d lumnar 9 (dsp "-
43c0: 20 49 74 65 6d 20 31 3a 5c 6e 22 29 20 22 20 22 Item 1:\n") " "
43d0: 20 28 77 69 74 68 2d 77 69 64 74 68 20 32 30 20 (with-width 20
43e0: 28 77 72 61 70 2d 6c 69 6e 65 73 20 22 54 68 65 (wrap-lines "The
43f0: 20 74 65 78 74 20 68 65 72 65 20 69 73 20 69 6e text here is in
4400: 64 65 6e 74 65 64 20 61 63 63 6f 72 64 69 6e 67 dented according
4410: 20 74 6f 20 74 68 65 20 73 70 61 63 65 20 5c 22 to the space \"
4420: 49 74 65 6d 20 31 5c 22 20 74 61 6b 65 73 2c 20 Item 1\" takes,
4430: 61 6e 64 20 6f 6e 65 20 64 6f 65 73 20 6e 6f 74 and one does not
4440: 20 6b 6e 6f 77 6e 20 77 68 61 74 20 67 6f 65 73 known what goes
4450: 20 68 65 72 65 2e 22 29 29 29 29 29 0a 0a 28 74 here.")))))..(t
4460: 65 73 74 0a 22 2d 20 49 74 65 6d 20 31 3a 20 54 est."- Item 1: T
4470: 68 65 20 74 65 78 74 20 68 65 72 65 20 69 73 2d he text here is-
4480: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4490: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
44a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
44b0: 2d 2d 2d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 69 6e ---.--------- in
44c0: 64 65 6e 74 65 64 20 61 63 63 6f 72 64 69 6e 67 dented according
44d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
44e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
44f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4500: 2d 2d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 74 6f 20 --.--------- to
4510: 74 68 65 20 73 70 61 63 65 20 5c 22 49 74 65 6d the space \"Item
4520: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4530: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4540: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4550: 2d 2d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 31 5c 22 --.--------- 1\"
4560: 20 74 61 6b 65 73 2c 20 61 6e 64 20 6f 6e 65 2d takes, and one-
4570: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4580: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4590: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
45a0: 2d 2d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 64 6f 65 --.--------- doe
45b0: 73 20 6e 6f 74 20 6b 6e 6f 77 6e 20 77 68 61 74 s not known what
45c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
45d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
45e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
45f0: 2d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 67 6f 65 73 -.--------- goes
4600: 20 68 65 72 65 2e 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d here.----------
4610: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4620: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
4640: 0a 22 0a 20 20 20 20 28 66 6d 74 20 23 66 20 28 .". (fmt #f (
4650: 70 61 64 2d 63 68 61 72 20 23 5c 2d 20 28 63 6f pad-char #\- (co
4660: 6c 75 6d 6e 61 72 20 39 20 28 64 73 70 20 22 2d lumnar 9 (dsp "-
4670: 20 49 74 65 6d 20 31 3a 5c 6e 22 29 20 22 20 22 Item 1:\n") " "
4680: 20 28 77 69 74 68 2d 77 69 64 74 68 20 32 30 20 (with-width 20
4690: 28 77 72 61 70 2d 6c 69 6e 65 73 20 22 54 68 65 (wrap-lines "The
46a0: 20 74 65 78 74 20 68 65 72 65 20 69 73 20 69 6e text here is in
46b0: 64 65 6e 74 65 64 20 61 63 63 6f 72 64 69 6e 67 dented according
46c0: 20 74 6f 20 74 68 65 20 73 70 61 63 65 20 5c 22 to the space \"
46d0: 49 74 65 6d 20 31 5c 22 20 74 61 6b 65 73 2c 20 Item 1\" takes,
46e0: 61 6e 64 20 6f 6e 65 20 64 6f 65 73 20 6e 6f 74 and one does not
46f0: 20 6b 6e 6f 77 6e 20 77 68 61 74 20 67 6f 65 73 known what goes
4700: 20 68 65 72 65 2e 22 29 29 29 29 29 29 0a 0a 28 here."))))))..(
4710: 74 65 73 74 0a 22 61 20 20 20 7c 20 31 32 33 0a test."a | 123.
4720: 62 63 20 20 7c 20 34 35 0a 64 65 66 20 7c 20 36 bc | 45.def | 6
4730: 0a 22 0a 20 20 20 20 28 66 6d 74 20 23 66 20 28 .". (fmt #f (
4740: 77 69 74 68 2d 77 69 64 74 68 0a 20 20 20 20 20 with-width.
4750: 20 20 20 20 20 20 20 20 32 30 0a 20 20 20 20 20 20.
4760: 20 20 20 20 20 20 20 20 28 74 61 62 75 6c 61 72 (tabular
4770: 20 28 64 73 70 20 22 61 5c 6e 62 63 5c 6e 64 65 (dsp "a\nbc\nde
4780: 66 5c 6e 22 29 20 22 20 7c 20 22 20 28 64 73 70 f\n") " | " (dsp
4790: 20 22 31 32 33 5c 6e 34 35 5c 6e 36 5c 6e 22 29 "123\n45\n6\n")
47a0: 29 29 29 29 0a 0a 3b 3b 20 6d 69 73 63 20 65 78 ))))..;; misc ex
47b0: 74 72 61 73 0a 0a 28 64 65 66 69 6e 65 20 28 73 tras..(define (s
47c0: 74 72 69 6e 67 2d 68 69 64 65 2d 70 61 73 73 77 tring-hide-passw
47d0: 6f 72 64 73 20 73 74 72 29 0a 20 20 28 73 74 72 ords str). (str
47e0: 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20 28 ing-substitute (
47f0: 72 65 67 65 78 70 20 22 28 70 61 73 73 28 3f 3a regexp "(pass(?:
4800: 77 28 3f 3a 6f 72 29 3f 64 29 3f 5c 5c 73 3f 5b w(?:or)?d)?\\s?[
4810: 3a 3d 3e 5d 5c 5c 73 2b 29 5c 5c 53 2b 22 20 23 :=>]\\s+)\\S+" #
4820: 74 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 t).
4830: 20 20 20 20 20 20 20 20 22 5c 5c 31 2a 2a 2a 2a "\\1****
4840: 2a 2a 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 **".
4850: 20 20 20 20 20 20 20 20 20 73 74 72 0a 20 20 20 str.
4860: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4870: 20 20 23 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 #t))..(define
4880: 68 69 64 65 2d 70 61 73 73 77 6f 72 64 73 0a 20 hide-passwords.
4890: 20 28 6d 61 6b 65 2d 73 74 72 69 6e 67 2d 66 6d (make-string-fm
48a0: 74 2d 74 72 61 6e 73 66 6f 72 6d 65 72 20 73 74 t-transformer st
48b0: 72 69 6e 67 2d 68 69 64 65 2d 70 61 73 73 77 6f ring-hide-passwo
48c0: 72 64 73 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 rds))..(define (
48d0: 73 74 72 69 6e 67 2d 6d 61 6e 67 6c 65 2d 65 6d string-mangle-em
48e0: 61 69 6c 20 73 74 72 29 0a 20 20 28 73 74 72 69 ail str). (stri
48f0: 6e 67 2d 73 75 62 73 74 69 74 75 74 65 0a 20 20 ng-substitute.
4900: 20 28 72 65 67 65 78 70 20 22 5c 5c 62 28 5b 2d (regexp "\\b([-
4910: 2b 2e 5c 5c 77 5d 2b 29 40 28 28 3f 3a 5b 2d 2b +.\\w]+)@((?:[-+
4920: 5c 5c 77 5d 2b 5c 5c 2e 29 2b 5b 61 2d 7a 5d 7b \\w]+\\.)+[a-z]{
4930: 32 2c 34 7d 29 5c 5c 62 22 20 23 74 29 0a 20 20 2,4})\\b" #t).
4940: 20 22 5c 5c 31 20 5f 61 74 5f 20 5c 5c 32 22 0a "\\1 _at_ \\2".
4950: 20 20 20 73 74 72 0a 20 20 20 23 74 29 29 0a 0a str. #t))..
4960: 28 64 65 66 69 6e 65 20 6d 61 6e 67 6c 65 2d 65 (define mangle-e
4970: 6d 61 69 6c 0a 20 20 28 6d 61 6b 65 2d 73 74 72 mail. (make-str
4980: 69 6e 67 2d 66 6d 74 2d 74 72 61 6e 73 66 6f 72 ing-fmt-transfor
4990: 6d 65 72 20 73 74 72 69 6e 67 2d 6d 61 6e 67 6c mer string-mangl
49a0: 65 2d 65 6d 61 69 6c 29 29 0a 0a 28 74 65 73 74 e-email))..(test
49b0: 2d 65 6e 64 29 0a -end).