summaryrefslogtreecommitdiffstats
path: root/slib_7.html
blob: 932a04267e03819f232b9b0418d99e2a4c1a7c41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html40/loose.dtd">
<HTML>
<!-- Created on January, 10 2005 by texi2html 1.66 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<HEAD>
<TITLE>SLIB: Other Packages</TITLE>

<META NAME="description" CONTENT="SLIB: Other Packages">
<META NAME="keywords" CONTENT="SLIB: Other Packages">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.66">

</HEAD>

<BODY LANG="en" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">

<A NAME="SEC183"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_6.html#SEC182"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_6.html#SEC140"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 7. Other Packages </H1>
<!--docid::SEC183::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC184">7.1 Data Structures</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Various data structures.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC207">7.2 Sorting and Searching</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC225">7.3 Procedures</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Miscellaneous utility procedures.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC235">7.4 Standards Support</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Support for Scheme Standards.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC263">7.5 Session Support</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">REPL and Debugging.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC269">7.6 System Interface</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'system, 'getenv, and other programs.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC276">7.7 Extra-SLIB Packages</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Outside the envelope.</TD></TR>
</TABLE>
<P>

<A NAME="Data Structures"></A>
<HR SIZE="6">
<A NAME="SEC184"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC185"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 7.1 Data Structures </H2>
<!--docid::SEC184::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC185">7.1.1 Arrays</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'array</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC186">7.1.2 Subarrays</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'subarray</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC187">7.1.3 Array Mapping</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'array-for-each</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC188">7.1.4 Association Lists</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'alist</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC189">7.1.5 Byte</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'byte</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC190">7.1.6 Byte/Number Conversions</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'byte-number</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC192">7.1.7 MAT-File Format</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'matfile</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC193">7.1.8 Portable Image Files</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'pnm</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC194">7.1.9 Collections</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'collect</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC195">7.1.10 Dynamic Data Type</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'dynamic</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC196">7.1.11 Hash Tables</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'hash-table</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC197">7.1.12 Macroless Object System</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'object</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC204">7.1.16 Priority Queues</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'priority-queue</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC205">7.1.17 Queues</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'queue</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC206">7.1.18 Records</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'record</TD></TR>
</TABLE>
<P>

<A NAME="Arrays"></A>
<HR SIZE="6">
<A NAME="SEC185"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC186"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.1 Arrays </H3>
<!--docid::SEC185::-->
<P>

<CODE>(require 'array)</CODE>
<A NAME="IDX1094"></A>
</P>
<P>

<A NAME="IDX1095"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array?</B> <I>obj</I>
<DD><P>

Returns <CODE>#t</CODE> if the <VAR>obj</VAR> is an array, and <CODE>#f</CODE> if not.
</P>
</DL>
<EM>Note:</EM> Arrays are not disjoint from other Scheme types.  Strings
and vectors also satisfy <CODE>array?</CODE>.  A disjoint array predicate can
be written:
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define (strict-array? obj)
  (and (array? obj) (not (string? obj)) (not (vector? obj))))
</pre></td></tr></table><P>

<A NAME="IDX1096"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array=?</B> <I>array1 array2</I>
<DD><P>

Returns <CODE>#t</CODE> if <VAR>array1</VAR> and <VAR>array2</VAR> have the same rank and shape and the
corresponding elements of <VAR>array1</VAR> and <VAR>array2</VAR> are <CODE>equal?</CODE>.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(array=? (create-array '#(foo) 3 3)
         (create-array '#(foo) '(0 2) '(0 2)))
  => #t
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1097"></A>
</P>
<DL>
<DT><U>Function:</U> <B>create-array</B> <I>prototype bound1 bound2 <small>...</small></I>
<DD><P>

Creates and returns an array of type <VAR>prototype</VAR> with dimensions <VAR>bound1</VAR>, <VAR>bound2</VAR>,
<small>...</small> and filled with elements from <VAR>prototype</VAR>.  <VAR>prototype</VAR> must be an array,
vector, or string.  The implementation-dependent type of the returned
array will be the same as the type of <VAR>prototype</VAR>; except if that would be a
vector or string with non-zero origin, in which case some variety of
array will be returned.
</P>
<P>

If the <VAR>prototype</VAR> has no elements, then the initial contents of the returned
array are unspecified.  Otherwise, the returned array will be filled
with the element at the origin of <VAR>prototype</VAR>.
</P>
</DL>
These functions return a prototypical uniform-array enclosing the
optional argument (which must be of the correct type).  If the
uniform-array type is supported by the implementation, then it is
returned; defaulting to the next larger precision type; resorting
finally to vector.
<P>

<A NAME="IDX1098"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ac64</B> <I>z</I>
<DD><P>

<A NAME="IDX1099"></A>
<DT><U>Function:</U> <B>ac64</B>
<DD>Returns a high-precision complex uniform-array prototype.
</P>
</DL>
<P>

<A NAME="IDX1100"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ac32</B> <I>z</I>
<DD><P>

<A NAME="IDX1101"></A>
<DT><U>Function:</U> <B>ac32</B>
<DD>Returns a complex uniform-array prototype.
</P>
</DL>
<P>

<A NAME="IDX1102"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ar64</B> <I>x</I>
<DD><P>

<A NAME="IDX1103"></A>
<DT><U>Function:</U> <B>ar64</B>
<DD>Returns a high-precision real uniform-array prototype.
</P>
</DL>
<P>

<A NAME="IDX1104"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ar32</B> <I>x</I>
<DD><P>

<A NAME="IDX1105"></A>
<DT><U>Function:</U> <B>ar32</B>
<DD>Returns a real uniform-array prototype.
</P>
</DL>
<P>

<A NAME="IDX1106"></A>
</P>
<DL>
<DT><U>Function:</U> <B>as64</B> <I>n</I>
<DD><P>

<A NAME="IDX1107"></A>
<DT><U>Function:</U> <B>as64</B>
<DD>Returns an exact signed integer uniform-array prototype with at least
64 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1108"></A>
</P>
<DL>
<DT><U>Function:</U> <B>as32</B> <I>n</I>
<DD><P>

<A NAME="IDX1109"></A>
<DT><U>Function:</U> <B>as32</B>
<DD>Returns an exact signed integer uniform-array prototype with at least
32 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1110"></A>
</P>
<DL>
<DT><U>Function:</U> <B>as16</B> <I>n</I>
<DD><P>

<A NAME="IDX1111"></A>
<DT><U>Function:</U> <B>as16</B>
<DD>Returns an exact signed integer uniform-array prototype with at least
16 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1112"></A>
</P>
<DL>
<DT><U>Function:</U> <B>as8</B> <I>n</I>
<DD><P>

<A NAME="IDX1113"></A>
<DT><U>Function:</U> <B>as8</B>
<DD>Returns an exact signed integer uniform-array prototype with at least
8 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1114"></A>
</P>
<DL>
<DT><U>Function:</U> <B>au64</B> <I>k</I>
<DD><P>

<A NAME="IDX1115"></A>
<DT><U>Function:</U> <B>au64</B>
<DD>Returns an exact non-negative integer uniform-array prototype with at
least 64 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1116"></A>
</P>
<DL>
<DT><U>Function:</U> <B>au32</B> <I>k</I>
<DD><P>

<A NAME="IDX1117"></A>
<DT><U>Function:</U> <B>au32</B>
<DD>Returns an exact non-negative integer uniform-array prototype with at
least 32 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1118"></A>
</P>
<DL>
<DT><U>Function:</U> <B>au16</B> <I>k</I>
<DD><P>

<A NAME="IDX1119"></A>
<DT><U>Function:</U> <B>au16</B>
<DD>Returns an exact non-negative integer uniform-array prototype with at
least 16 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1120"></A>
</P>
<DL>
<DT><U>Function:</U> <B>au8</B> <I>k</I>
<DD><P>

<A NAME="IDX1121"></A>
<DT><U>Function:</U> <B>au8</B>
<DD>Returns an exact non-negative integer uniform-array prototype with at
least 8 bits of precision.
</P>
</DL>
<P>

<A NAME="IDX1122"></A>
</P>
<DL>
<DT><U>Function:</U> <B>at1</B> <I>bool</I>
<DD><P>

<A NAME="IDX1123"></A>
<DT><U>Function:</U> <B>at1</B>
<DD>Returns a boolean uniform-array prototype.
</P>
</DL>
When constructing an array, <VAR>bound</VAR> is either an inclusive range of
indices expressed as a two element list, or an upper bound expressed as
a single integer.  So
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(create-array '#(foo) 3 3) == (create-array '#(foo) '(0 2) '(0 2))
</pre></td></tr></table><P>

<A NAME="IDX1124"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-shared-array</B> <I>array mapper bound1 bound2 <small>...</small></I>
<DD><P>

<CODE>make-shared-array</CODE> can be used to create shared subarrays of other
arrays.  The <VAR>mapper</VAR> is a function that translates coordinates in
the new array into coordinates in the old array.  A <VAR>mapper</VAR> must be
linear, and its range must stay within the bounds of the old array, but
it can be otherwise arbitrary.  A simple example:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define fred (create-array '#(#f) 8 8))
(define freds-diagonal
  (make-shared-array fred (lambda (i) (list i i)) 8))
(array-set! freds-diagonal 'foo 3)
(array-ref fred 3 3)
   => FOO
(define freds-center
  (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j)))
                     2 2))
(array-ref freds-center 0 0)
   => FOO
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1125"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-rank</B> <I>obj</I>
<DD><P>

Returns the number of dimensions of <VAR>obj</VAR>.  If <VAR>obj</VAR> is not an array, 0 is
returned.
</P>
</DL>
<P>

<A NAME="IDX1126"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-shape</B> <I>array</I>
<DD><P>

Returns a list of inclusive bounds.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(array-shape (create-array '#() 3 5))
   => ((0 2) (0 4))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1127"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-dimensions</B> <I>array</I>
<DD><P>

<CODE>array-dimensions</CODE> is similar to <CODE>array-shape</CODE> but replaces
elements with a 0 minimum with one greater than the maximum.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(array-dimensions (create-array '#() 3 5))
   => (3 5)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1128"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-in-bounds?</B> <I>array index1 index2 <small>...</small></I>
<DD><P>

Returns <CODE>#t</CODE> if its arguments would be acceptable to
<CODE>array-ref</CODE>.
</P>
</DL>
<P>

<A NAME="IDX1129"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-ref</B> <I>array index1 index2 <small>...</small></I>
<DD><P>

Returns the (<VAR>index1</VAR>, <VAR>index2</VAR>, <small>...</small>) element of <VAR>array</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1130"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>array-set!</B> <I>array obj index1 index2 <small>...</small></I>
<DD><P>

Stores <VAR>obj</VAR> in the (<VAR>index1</VAR>, <VAR>index2</VAR>, <small>...</small>) element of <VAR>array</VAR>.  The value returned
by <CODE>array-set!</CODE> is unspecified.
</P>
</DL>
<P>

<A NAME="Subarrays"></A>
<HR SIZE="6">
<A NAME="SEC186"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC185"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC187"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.2 Subarrays </H3>
<!--docid::SEC186::-->
<P>

<CODE>(require 'subarray)</CODE>
<A NAME="IDX1131"></A>
</P>
<P>

<A NAME="IDX1132"></A>
</P>
<DL>
<DT><U>Function:</U> <B>subarray</B> <I>array select <small>...</small></I>
<DD><P>

selects a subset of an array.  For <VAR>array</VAR> of rank n, there must be at least
n <VAR>selects</VAR> arguments.  For 0 &lt;= <I>j</I> &lt; n, <VAR>selects</VAR><I>j</I> is either an integer, a
list of two integers within the range for the <I>j</I>th index, or #f.
</P>
<P>

When <VAR>selects</VAR><I>j</I> is a list of two integers, then the <I>j</I>th index is
restricted to that subrange in the returned array.
</P>
<P>

When <VAR>selects</VAR><I>j</I> is #f, then the full range of the <I>j</I>th index is
accessible in the returned array.  An elided argument is equivalent to #f.
</P>
<P>

When <VAR>selects</VAR><I>j</I> is an integer, then the rank of the returned array is
less than <VAR>array</VAR>, and only elements whose <I>j</I>th index equals <VAR>selects</VAR><I>j</I> are
shared.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>&gt; (define ra '#2A((a b c) (d e f)))
#&lt;unspecified&gt;
&gt; (subarray ra 0 #f)
#1A(a b c)
&gt; (subarray ra 1 #f)
#1A(d e f)
&gt; (subarray ra #f 1)
#1A(b e)
&gt; (subarray ra '(0 1) #f)
#2A((a b c) (d e f))
&gt; (subarray ra #f '(0 1))
#2A((a b) (d e))
&gt; (subarray ra #f '(1 2))
#2A((b c) (e f))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1133"></A>
</P>
<DL>
<DT><U>Function:</U> <B>subarray0</B> <I>array select <small>...</small></I>
<DD><P>

Behaves like subarray, but aligns the returned array origin to
0 <small>...</small>.
</P>
</DL>
<P>

<A NAME="IDX1134"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-align</B> <I>array coord <small>...</small></I>
<DD><P>

Returns an array shared with <VAR>array</VAR> but with a different origin.  The <VAR>coords</VAR>
are the exact integer coordinates of the new origin.  Indexes
corresponding to missing or #f coordinates are not realigned.
</P>
<P>

For example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define ra2 (create-array '#(5) '(5 9) '(-4 0)))
(array-shape ra2)                       => ((5 9) (-4 0))
(array-shape (array-align ra2 0 0))     => ((0 4) (0 4))
(array-shape (array-align ra2 0))       => ((0 4) (-4 0))
(array-shape (array-align ra2))         => ((5 9) (-4 0))
(array-shape (array-align ra2 0 #f))    => ((0 4) (-4 0))
(array-shape (array-align ra2 #f 0))    => ((5 9) (0 4))
</pre></td></tr></table></DL>
  
<A NAME="IDX1135"></A>
<DL>
<DT><U>Function:</U> <B>array-trim</B> <I>array trim <small>...</small></I>
<DD><P>

Returns a subarray sharing contents with <VAR>array</VAR> except for slices removed
from either side of each dimension.  Each of the <VAR>trims</VAR> is an exact
integer indicating how much to trim.  A positive <VAR>s</VAR> trims the
data from the lower end and reduces the upper bound of the result; a
negative <VAR>s</VAR> trims from the upper end and increases the lower
bound.
</P>
<P>

For example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(array-trim '#(0 1 2 3 4) 1)  => #1A(1 2 3 4) ;; shape is ((0 3))
(array-trim '#(0 1 2 3 4) -1) => #1A(0 1 2 3) ;; shape is ((1 4))

(require 'array-for-each)
(define (centered-difference ra)
  (array-map - (array-trim ra 1) (array-trim ra -1)))
(define (forward-difference ra)
  (array-map - (array-trim ra 1) ra))
(define (backward-difference ra)
  (array-map - ra (array-trim ra -1)))

(centered-difference '#(0 1 3 5 9 22))
  => #1A(3 4 6 17) ;;shape is ((1 4))
(backward-difference '#(0 1 3 5 9 22))
  => #1A(1 2 2 4 13) ;; shape is ((1 5))
(forward-difference '#(0 1 3 5 9 22))
  => #(1 2 2 4 13)  ;; shape is ((0 4))
</pre></td></tr></table></DL>
<P>

<A NAME="Array Mapping"></A>
<HR SIZE="6">
<A NAME="SEC187"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC186"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC188"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.3 Array Mapping </H3>
<!--docid::SEC187::-->
<P>

<CODE>(require 'array-for-each)</CODE>
<A NAME="IDX1136"></A>
</P>
<P>

<A NAME="IDX1137"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>array-map!</B> <I>array0 proc array1 <small>...</small></I>
<DD><P>

<VAR>array1</VAR>, <small>...</small> must have the same number of dimensions as
<VAR>array0</VAR> and have a range for each index which includes the range
for the corresponding index in <VAR>array0</VAR>.  <VAR>proc</VAR> is applied to
each tuple of elements of <VAR>array1</VAR> <small>...</small> and the result is stored
as the corresponding element in <VAR>array0</VAR>.  The value returned is
unspecified.  The order of application is unspecified.
</P>
</DL>
<P>

<A NAME="IDX1138"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-map</B> <I>prototype proc array1 array2 <small>...</small></I>
<DD><P>

<VAR>array2</VAR>, <small>...</small> must have the same number of dimensions as
<VAR>array1</VAR> and have a range for each index which includes the
range for the corresponding index in <VAR>array1</VAR>.  <VAR>proc</VAR> is
applied to each tuple of elements of <VAR>array1</VAR>, <VAR>array2</VAR>,
<small>...</small> and the result is stored as the corresponding element in a
new array of type <VAR>prototype</VAR>.  The new array is returned.  The
order of application is unspecified.
</P>
</DL>
<P>

<A NAME="IDX1139"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-for-each</B> <I>proc array0 <small>...</small></I>
<DD><P>

<VAR>proc</VAR> is applied to each tuple of elements of <VAR>array0</VAR> <small>...</small>
in row-major order.  The value returned is unspecified.
</P>
</DL>
<P>

<A NAME="IDX1140"></A>
</P>
<DL>
<DT><U>Function:</U> <B>array-indexes</B> <I>array</I>
<DD><P>

Returns an array of lists of indexes for <VAR>array</VAR> such that, if
<VAR>li</VAR> is a list of indexes for which <VAR>array</VAR> is defined,
(equal?  <VAR>li</VAR> (apply array-ref (array-indexes <VAR>array</VAR>)
<VAR>li</VAR>)).
</P>
</DL>
<P>

<A NAME="IDX1141"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>array-index-map!</B> <I>array proc</I>
<DD><P>

applies <VAR>proc</VAR> to the indices of each element of <VAR>array</VAR> in
turn, storing the result in the corresponding element.  The value
returned and the order of application are unspecified.
</P>
<P>

One can implement <VAR>array-indexes</VAR> as
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define (array-indexes array)
    (let ((ra (apply create-array '#() (array-shape array))))
      (array-index-map! ra (lambda x x))
      ra))
</pre></td></tr></table>Another example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define (apl:index-generator n)
    (let ((v (make-vector n 1)))
      (array-index-map! v (lambda (i) i))
      v))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1142"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>array-copy!</B> <I>source destination</I>
<DD><P>

Copies every element from vector or array <VAR>source</VAR> to the
corresponding element of <VAR>destination</VAR>.  <VAR>destination</VAR> must
have the same rank as <VAR>source</VAR>, and be at least as large in each
dimension.  The order of copying is unspecified.
</P>
</DL>
<P>

<A NAME="Association Lists"></A>
<HR SIZE="6">
<A NAME="SEC188"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC187"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC189"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.4 Association Lists </H3>
<!--docid::SEC188::-->
<P>

<CODE>(require 'alist)</CODE>
<A NAME="IDX1143"></A>
</P>
<P>

Alist functions provide utilities for treating a list of key-value pairs
as an associative database.  These functions take an equality predicate,
<VAR>pred</VAR>, as an argument.  This predicate should be repeatable,
symmetric, and transitive.
</P>
<P>

Alist functions can be used with a secondary index method such as hash
tables for improved performance.
</P>
<P>

<A NAME="IDX1144"></A>
</P>
<DL>
<DT><U>Function:</U> <B>predicate-&gt;asso</B> <I>pred</I>
<DD><P>

Returns an <EM>association function</EM> (like <CODE>assq</CODE>, <CODE>assv</CODE>, or
<A NAME="IDX1145"></A>
<CODE>assoc</CODE>) corresponding to <VAR>pred</VAR>.  The returned function
returns a key-value pair whose key is <CODE>pred</CODE>-equal to its first
argument or <CODE>#f</CODE> if no key in the alist is <VAR>pred</VAR>-equal to the
first argument.
</P>
</DL>
<P>

<A NAME="IDX1146"></A>
</P>
<DL>
<DT><U>Function:</U> <B>alist-inquirer</B> <I>pred</I>
<DD><P>

Returns a procedure of 2 arguments, <VAR>alist</VAR> and <VAR>key</VAR>, which
returns the value associated with <VAR>key</VAR> in <VAR>alist</VAR> or <CODE>#f</CODE> if
<VAR>key</VAR> does not appear in <VAR>alist</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1147"></A>
</P>
<DL>
<DT><U>Function:</U> <B>alist-associator</B> <I>pred</I>
<DD><P>

Returns a procedure of 3 arguments, <VAR>alist</VAR>, <VAR>key</VAR>, and
<VAR>value</VAR>, which returns an alist with <VAR>key</VAR> and <VAR>value</VAR>
associated.  Any previous value associated with <VAR>key</VAR> will be
lost.  This returned procedure may or may not have side effects on its
<VAR>alist</VAR> argument.  An example of correct usage is:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define put (alist-associator string-ci=?))
(define alist '())
(set! alist (put alist &quot;Foo&quot; 9))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1148"></A>
</P>
<DL>
<DT><U>Function:</U> <B>alist-remover</B> <I>pred</I>
<DD><P>

Returns a procedure of 2 arguments, <VAR>alist</VAR> and <VAR>key</VAR>, which
returns an alist with an association whose <VAR>key</VAR> is key removed.
This returned procedure may or may not have side effects on its
<VAR>alist</VAR> argument.  An example of correct usage is:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define rem (alist-remover string-ci=?))
(set! alist (rem alist &quot;foo&quot;))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1149"></A>
</P>
<DL>
<DT><U>Function:</U> <B>alist-map</B> <I>proc alist</I>
<DD><P>

Returns a new association list formed by mapping <VAR>proc</VAR> over the
keys and values of <VAR>alist</VAR>.   <VAR>proc</VAR> must be a function of 2
arguments which returns the new value part.
</P>
</DL>
<P>

<A NAME="IDX1150"></A>
</P>
<DL>
<DT><U>Function:</U> <B>alist-for-each</B> <I>proc alist</I>
<DD><P>

Applies <VAR>proc</VAR> to each pair of keys and values of <VAR>alist</VAR>.
<VAR>proc</VAR> must be a function of 2 arguments.  The returned value is
unspecified.
</P>
</DL>
<P>

<A NAME="Byte"></A>
<HR SIZE="6">
<A NAME="SEC189"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC188"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC190"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.5 Byte </H3>
<!--docid::SEC189::-->
<P>

<CODE>(require 'byte)</CODE>
<A NAME="IDX1151"></A>
</P>
<P>

Some algorithms are expressed in terms of arrays of small integers.
Using Scheme strings to implement these arrays is not portable vis-a-vis
the correspondence between integers and characters and non-ascii
character sets.  These functions abstract the notion of a <EM>byte</EM>.
<A NAME="IDX1152"></A>
<A NAME="IDX1153"></A>
</P>
<P>

<A NAME="IDX1154"></A>
</P>
<DL>
<DT><U>Function:</U> <B>byte-ref</B> <I>bytes k</I>
<DD><P>

<VAR>k</VAR> must be a valid index of <VAR>bytes</VAR>.  <CODE>byte-ref</CODE> returns byte <VAR>k</VAR> of <VAR>bytes</VAR> using
zero-origin indexing.
</P>
</DL>
<P>

<A NAME="IDX1155"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>byte-set!</B> <I>bytes k byte</I>
<DD><P>

<VAR>k</VAR> must be a valid index of <VAR>bytes</VAR>, and <VAR>byte</VAR> must be a small
nonnegative integer.  <CODE>byte-set!</CODE> stores <VAR>byte</VAR> in element <VAR>k</VAR> of <VAR>bytes</VAR> and
returns an unspecified value.  
</P>
</DL>
<P>

<A NAME="IDX1156"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-bytes</B> <I>k byte</I>
<DD><P>

<A NAME="IDX1157"></A>
<DT><U>Function:</U> <B>make-bytes</B> <I>k</I>
<DD><CODE>make-bytes</CODE> returns a newly allocated byte-array of length <VAR>k</VAR>.  If <VAR>byte</VAR> is
given, then all elements of the byte-array are initialized to <VAR>byte</VAR>,
otherwise the contents of the byte-array are unspecified.
</P>
</DL>
<P>

<A NAME="IDX1158"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes-length</B> <I>bytes</I>
<DD><P>

<CODE>bytes-length</CODE> returns length of byte-array <VAR>bytes</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1159"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes</B> <I>byte <small>...</small></I>
<DD><P>

Returns a newly allocated byte-array composed of the small
nonnegative arguments.
</P>
</DL>
<P>

<A NAME="IDX1160"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes-&gt;list</B> <I>bytes</I>
<DD><P>

<CODE>bytes-&gt;list</CODE> returns a newly allocated list of the bytes that make up the
given byte-array.
</P>
</DL>
<P>

<A NAME="IDX1161"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-&gt;bytes</B> <I>bytes</I>
<DD><P>

<CODE>list-&gt;bytes</CODE> returns a newly allocated byte-array formed from the small
nonnegative integers in the list <VAR>bytes</VAR>.
</P>
</DL>
<CODE>Bytes-&gt;list</CODE> and <CODE>list-&gt;bytes</CODE> are inverses so far as
<CODE>equal?</CODE> is concerned.
<A NAME="IDX1162"></A>
<P>

<A NAME="IDX1163"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes-copy</B> <I>bytes</I>
<DD><P>

Returns a newly allocated copy of the given <VAR>bytes</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1164"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>bytes-reverse!</B> <I>bytes</I>
<DD><P>

Reverses the order of byte-array <VAR>bytes</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1165"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes-reverse</B> <I>bytes</I>
<DD><P>

Returns a newly allocated bytes-array consisting of the elements of
<VAR>bytes</VAR> in reverse order.
</P>
</DL>
<A NAME="IDX1166"></A>
Input and output of bytes should be with ports opened in <EM>binary</EM>
<A NAME="IDX1167"></A>
mode (see section <A HREF="slib_2.html#SEC16">2.3 Input/Output</A>).  Calling <CODE>open-file</CODE> with 'rb or
<A NAME="IDX1168"></A>
'wb modes argument will return a binary port if the Scheme
implementation supports it.
<P>

<A NAME="IDX1169"></A>
</P>
<DL>
<DT><U>Function:</U> <B>write-byte</B> <I>byte port</I>
<DD><P>

<A NAME="IDX1170"></A>
<DT><U>Function:</U> <B>write-byte</B> <I>byte</I>
<DD>Writes the byte <VAR>byte</VAR> (not an external representation of the byte) to
the given <VAR>port</VAR> and returns an unspecified value.  The <VAR>port</VAR> argument may
be omitted, in which case it defaults to the value returned by
<CODE>current-output-port</CODE>.
<A NAME="IDX1171"></A>
</P>
</DL>
<P>

<A NAME="IDX1172"></A>
</P>
<DL>
<DT><U>Function:</U> <B>read-byte</B> <I>port</I>
<DD><P>

<A NAME="IDX1173"></A>
<DT><U>Function:</U> <B>read-byte</B>
<DD>Returns the next byte available from the input <VAR>port</VAR>, updating the <VAR>port</VAR>
to point to the following byte.  If no more bytes are available, an
end-of-file object is returned.  <VAR>port</VAR> may be omitted, in which case it
defaults to the value returned by <CODE>current-input-port</CODE>.
<A NAME="IDX1174"></A>
</P>
</DL>
When reading and writing binary numbers with <CODE>read-bytes</CODE> and
<CODE>write-bytes</CODE>, the sign of the length argument determines the
endianness (order) of bytes.  Positive treats them as big-endian,
the first byte input or output is highest order.  Negative treats
them as little-endian, the first byte input or output is the lowest
order.
<P>

Once read in, SLIB treats byte sequences as big-endian.  The
multi-byte sequences produced and used by number conversion routines
see section <A HREF="slib_7.html#SEC190">7.1.6 Byte/Number Conversions</A> are always big-endian.
</P>
<P>

<A NAME="IDX1175"></A>
</P>
<DL>
<DT><U>Function:</U> <B>read-bytes</B> <I>n port</I>
<DD><P>

<A NAME="IDX1176"></A>
<DT><U>Function:</U> <B>read-bytes</B> <I>n</I>
<DD><CODE>read-bytes</CODE> returns a newly allocated bytes-array filled with
<CODE>(abs <VAR>n</VAR>)</CODE> bytes read from <VAR>port</VAR>.  If <VAR>n</VAR> is positive, then
the first byte read is stored at index 0; otherwise the last byte
read is stored at index 0.  Note that the length of the returned
string will be less than <CODE>(abs <VAR>n</VAR>)</CODE> if <VAR>port</VAR> reaches
end-of-file.
</P>
<P>

<VAR>port</VAR> may be omitted, in which case it defaults to the value returned
by <CODE>current-input-port</CODE>.
</P>
</DL>
<P>

<A NAME="IDX1177"></A>
</P>
<DL>
<DT><U>Function:</U> <B>write-bytes</B> <I>bytes n port</I>
<DD><P>

<A NAME="IDX1178"></A>
<DT><U>Function:</U> <B>write-bytes</B> <I>bytes n</I>
<DD><CODE>write-bytes</CODE> writes <CODE>(abs <VAR>n</VAR>)</CODE> bytes to output-port <VAR>port</VAR>.  If <VAR>n</VAR> is
positive, then the first byte written is index 0 of <VAR>bytes</VAR>; otherwise
the last byte written is index 0 of <VAR>bytes</VAR>.  <CODE>write-bytes</CODE> returns an unspecified
value.
</P>
<P>

<VAR>port</VAR> may be omitted, in which case it defaults to the value returned
by <CODE>current-output-port</CODE>.
</P>
</DL>
<CODE>substring-read!</CODE> and <CODE>substring-write</CODE> provide
lower-level procedures for reading and writing blocks of bytes.  The
relative size of <VAR>start</VAR> and <VAR>end</VAR> determines the order of
writing.
<P>

<A NAME="IDX1179"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>substring-read!</B> <I>string start end port</I>
<DD><P>

<A NAME="IDX1180"></A>
<DT><U>Procedure:</U> <B>substring-read!</B> <I>string start end</I>
<DD>Fills <VAR>string</VAR> with up to <CODE>(abs (- <VAR>start</VAR> <VAR>end</VAR>))</CODE> bytes
read from <VAR>port</VAR>.  The first byte read is stored at index <VAR>string</VAR>.
<CODE>substring-read!</CODE> returns the number of bytes read.
</P>
<P>

<VAR>port</VAR> may be omitted, in which case it defaults to the value returned
by <CODE>current-input-port</CODE>.
</P>
</DL>
<P>

<A NAME="IDX1181"></A>
</P>
<DL>
<DT><U>Function:</U> <B>substring-write</B> <I>string start end port</I>
<DD><P>

<A NAME="IDX1182"></A>
<DT><U>Function:</U> <B>substring-write</B> <I>string start end</I>
<DD><CODE>substring-write</CODE> writes <CODE>(abs (- <VAR>start</VAR> <VAR>end</VAR>))</CODE> bytes to
output-port <VAR>port</VAR>.  The first byte written is index <VAR>start</VAR> of <VAR>string</VAR>.  <CODE>substring-write</CODE>
returns the number of bytes written.
</P>
<P>

<VAR>port</VAR> may be omitted, in which case it defaults to the value returned
by <CODE>current-output-port</CODE>.
</P>
</DL>
<P>

<A NAME="Byte/Number Conversions"></A>
<HR SIZE="6">
<A NAME="SEC190"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC189"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC192"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.6 Byte/Number Conversions </H3>
<!--docid::SEC190::-->
<P>

<CODE>(require 'byte-number)</CODE>
<A NAME="IDX1183"></A>
</P>
<P>

The multi-byte sequences produced and used by numeric conversion
routines are always big-endian.  Endianness can be changed during
reading and writing bytes using <CODE>read-bytes</CODE> and
<CODE>write-bytes</CODE> See section <A HREF="slib_7.html#SEC189">read-bytes</A>.
</P>
<P>

The sign of the length argument to bytes/integer conversion
procedures determines the signedness of the number.
</P>
<P>

<A NAME="IDX1184"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes-&gt;integer</B> <I>bytes n</I>
<DD><P>

Converts the first <CODE>(abs <VAR>n</VAR>)</CODE> bytes of big-endian <VAR>bytes</VAR> array
to an integer.  If <VAR>n</VAR> is negative then the integer coded by the
bytes are treated as two's-complement (can be negative).
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(bytes-&gt;integer (bytes   0   0   0  15) -4)   =>          15
(bytes-&gt;integer (bytes   0   0   0  15)  4)   =>          15
(bytes-&gt;integer (bytes 255 255 255 255) -4)   =>          -1
(bytes-&gt;integer (bytes 255 255 255 255)  4)   =>  4294967295
(bytes-&gt;integer (bytes 128   0   0   0) -4)   => -2147483648
(bytes-&gt;integer (bytes 128   0   0   0)  4)   =>  2147483648
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1185"></A>
</P>
<DL>
<DT><U>Function:</U> <B>integer-&gt;bytes</B> <I>n len</I>
<DD><P>

Converts the integer <VAR>n</VAR> to a byte-array of <CODE>(abs <VAR>n</VAR>)</CODE>
bytes.  If <VAR>n</VAR> and <VAR>len</VAR> are both negative, then the bytes in the
returned array are coded two's-complement.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(bytes-&gt;list (integer-&gt;bytes          15 -4))   => (0 0 0 15)
(bytes-&gt;list (integer-&gt;bytes          15  4))   => (0 0 0 15)
(bytes-&gt;list (integer-&gt;bytes          -1 -4))   => (255 255 255 255)
(bytes-&gt;list (integer-&gt;bytes  4294967295  4))   => (255 255 255 255)
(bytes-&gt;list (integer-&gt;bytes -2147483648 -4))   => (128 0 0 0)
(bytes-&gt;list (integer-&gt;bytes  2147483648  4))   => (128 0 0 0)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1186"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes-&gt;ieee-float</B> <I>bytes</I>
<DD><P>

<VAR>bytes</VAR> must be a 4-element byte-array.  <CODE>bytes-&gt;ieee-float</CODE> calculates and returns the
value of <VAR>bytes</VAR> interpreted as a big-endian IEEE 4-byte (32-bit) number.
</P>
</DL>
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(bytes-&gt;ieee-float (bytes #x40    0 0 0))  =>  2.0
(bytes-&gt;ieee-float (bytes #x40 #xd0 0 0))  =>  6.5
(bytes-&gt;ieee-float (bytes #xc0 #xd0 0 0))  => -6.5

(bytes-&gt;ieee-float (bytes    0 #x80 0 0))  => 11.754943508222875e-39
(bytes-&gt;ieee-float (bytes    0 #x40 0 0))  =>  5.877471754111437e-39
(bytes-&gt;ieee-float (bytes    0    0 0 1))  =>  1.401298464324817e-45

(bytes-&gt;ieee-float (bytes #xff #x80 0 0))  => -1/0
(bytes-&gt;ieee-float (bytes #x7f #x80 0 0))  =>  1/0
(bytes-&gt;ieee-float (bytes #x7f #x80 0 1))  =>  0/0
</pre></td></tr></table><P>

<A NAME="IDX1187"></A>
</P>
<DL>
<DT><U>Function:</U> <B>bytes-&gt;ieee-double</B> <I>bytes</I>
<DD><P>

<VAR>bytes</VAR> must be a 8-element byte-array.  <CODE>bytes-&gt;ieee-double</CODE> calculates and returns the
value of <VAR>bytes</VAR> interpreted as a big-endian IEEE 8-byte (64-bit) number.
</P>
</DL>
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(bytes-&gt;ieee-double (bytes    0    0 0 0 0 0 0 0))  =>  0.0
(bytes-&gt;ieee-double (bytes #x40    0 0 0 0 0 0 0))  =>  2
(bytes-&gt;ieee-double (bytes #x40 #x1A 0 0 0 0 0 0))  =>  6.5
(bytes-&gt;ieee-double (bytes #xC0 #x1A 0 0 0 0 0 0))  => -6.5

(bytes-&gt;ieee-double (bytes 0 8 0 0 0 0 0 0)) => 11.125369292536006e-309
(bytes-&gt;ieee-double (bytes 0 4 0 0 0 0 0 0)) =>  5.562684646268003e-309
(bytes-&gt;ieee-double (bytes 0 0 0 0 0 0 0 1)) =>  4.0e-324

(bytes-&gt;ieee-double (bytes #xFF #xF0 0 0 0 0 0 0))  => -1/0
(bytes-&gt;ieee-double (bytes #x7F #xF0 0 0 0 0 0 0))  =>  1/0
(bytes-&gt;ieee-double (bytes #x7F #xF8 0 0 0 0 0 0))  =>  0/0
</pre></td></tr></table><P>

<A NAME="IDX1188"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ieee-float-&gt;bytes</B> <I>x</I>
<DD><P>

Returns a 4-element byte-array encoding the IEEE single-precision
floating-point of <VAR>x</VAR>.
</P>
</DL>
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(bytes-&gt;list (ieee-float-&gt;bytes  2.0))                    => (64    0 0 0)
(bytes-&gt;list (ieee-float-&gt;bytes  6.5))                    => (64  208 0 0)
(bytes-&gt;list (ieee-float-&gt;bytes -6.5))                    => (192 208 0 0)

(bytes-&gt;list (ieee-float-&gt;bytes 11.754943508222875e-39))  => (  0 128 0 0)
(bytes-&gt;list (ieee-float-&gt;bytes  5.877471754111438e-39))  => (  0  64 0 0)
(bytes-&gt;list (ieee-float-&gt;bytes  1.401298464324817e-45))  => (  0   0 0 1)

(bytes-&gt;list (ieee-float-&gt;bytes -1/0))                    => (255 128 0 0)
(bytes-&gt;list (ieee-float-&gt;bytes  1/0))                    => (127 128 0 0)
(bytes-&gt;list (ieee-float-&gt;bytes  0/0))                    => (127 128 0 1)
</pre></td></tr></table><P>

<A NAME="IDX1189"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ieee-double-&gt;bytes</B> <I>x</I>
<DD><P>

Returns a 8-element byte-array encoding the IEEE double-precision
floating-point of <VAR>x</VAR>.
</P>
</DL>
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(bytes-&gt;list (ieee-double-&gt;bytes  2.0)) => (64    0 0 0 0 0 0 0)
(bytes-&gt;list (ieee-double-&gt;bytes  6.5)) => (64   26 0 0 0 0 0 0)
(bytes-&gt;list (ieee-double-&gt;bytes -6.5)) => (192  26 0 0 0 0 0 0)

(bytes-&gt;list (ieee-double-&gt;bytes 11.125369292536006e-309))
                                        => (  0   8 0 0 0 0 0 0)
(bytes-&gt;list (ieee-double-&gt;bytes  5.562684646268003e-309))
                                        => (  0   4 0 0 0 0 0 0)
(bytes-&gt;list (ieee-double-&gt;bytes  4.0e-324))
                                        => (  0   0 0 0 0 0 0 1)

(bytes-&gt;list (ieee-double-&gt;bytes -1/0)) => (255 240 0 0 0 0 0 0)
(bytes-&gt;list (ieee-double-&gt;bytes  1/0)) => (127 240 0 0 0 0 0 0)
(bytes-&gt;list (ieee-double-&gt;bytes  0/0)) => (127 248 0 0 0 0 0 0)
</pre></td></tr></table><P>

<A NAME="SEC191"></A>
<H4> Byte Collation Order </H4>
<!--docid::SEC191::-->
<P>

The <CODE>string&lt;?</CODE> ordering of big-endian byte-array
representations of fixed and IEEE floating-point numbers agrees with
the numerical ordering only when those numbers are non-negative.
</P>
<P>

Straighforward modification of these formats can extend the
byte-collating order to work for their entire ranges.  This
agreement enables the full range of numbers as keys in
<EM>indexed-sequential-access-method</EM> databases.
<A NAME="IDX1190"></A>
</P>
<P>

<A NAME="IDX1191"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>integer-byte-collate!</B> <I>byte-vector</I>
<DD><P>

Modifies sign bit of <VAR>byte-vector</VAR> so that <CODE>string&lt;?</CODE> ordering of
two's-complement byte-vectors matches numerical order.  <CODE>integer-byte-collate!</CODE> returns
<VAR>byte-vector</VAR> and is its own functional inverse.
</P>
</DL>
<P>

<A NAME="IDX1192"></A>
</P>
<DL>
<DT><U>Function:</U> <B>integer-byte-collate</B> <I>byte-vector</I>
<DD><P>

Returns copy of <VAR>byte-vector</VAR> with sign bit modified so that <CODE>string&lt;?</CODE>
ordering of two's-complement byte-vectors matches numerical order.
<CODE>integer-byte-collate</CODE> is its own functional inverse.
</P>
</DL>
<P>

<A NAME="IDX1193"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>ieee-byte-collate!</B> <I>byte-vector</I>
<DD><P>

Modifies <VAR>byte-vector</VAR> so that <CODE>string&lt;?</CODE> ordering of IEEE floating-point
byte-vectors matches numerical order.  <CODE>ieee-byte-collate!</CODE> returns <VAR>byte-vector</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1194"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>ieee-byte-decollate!</B> <I>byte-vector</I>
<DD><P>

Given <VAR>byte-vector</VAR> modified by <CODE>IEEE-byte-collate!</CODE>, reverses the <VAR>byte-vector</VAR>
modifications.
</P>
</DL>
<P>

<A NAME="IDX1195"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ieee-byte-collate</B> <I>byte-vector</I>
<DD><P>

Returns copy of <VAR>byte-vector</VAR> encoded so that <CODE>string&lt;?</CODE> ordering of IEEE
floating-point byte-vectors matches numerical order.
</P>
</DL>
<P>

<A NAME="IDX1196"></A>
</P>
<DL>
<DT><U>Function:</U> <B>ieee-byte-decollate</B> <I>byte-vector</I>
<DD><P>

Given <VAR>byte-vector</VAR> returned by <CODE>IEEE-byte-collate</CODE>, reverses the <VAR>byte-vector</VAR>
modifications.
</P>
</DL>
<P>

<A NAME="MAT-File Format"></A>
<HR SIZE="6">
<A NAME="SEC192"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC190"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC193"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.7 MAT-File Format </H3>
<!--docid::SEC192::-->
<P>

<CODE>(require 'matfile)</CODE>
<A NAME="IDX1197"></A>
<A NAME="IDX1198"></A>
</P>
<P>

<A HREF="http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf">http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf</A>
</P>
<P>

This package reads MAT-File Format version 4 (MATLAB) binary data
files.  MAT-files written from big-endian or little-endian computers
having IEEE format numbers are currently supported.  Support for files
written from VAX or Cray machines could also be added.
</P>
<P>

The numeric and text matrix types handled; support for <EM>sparse</EM>
<A NAME="IDX1199"></A>
matrices awaits a sample file.
</P>
<P>

<A NAME="IDX1200"></A>
</P>
<DL>
<DT><U>Function:</U> <B>matfile:read</B> <I>filename</I>
<DD><VAR>filename</VAR> should be a string naming an existing file containing a
MATLAB Version 4 MAT-File.  The <CODE>matfile:read</CODE> procedure reads matrices from the
file and returns a list of the results; a list of the name string and
array for each matrix.
</DL>
<P>

<A NAME="IDX1201"></A>
</P>
<DL>
<DT><U>Function:</U> <B>matfile:load</B> <I>filename</I>
<DD><VAR>filename</VAR> should be a string naming an existing file containing a
MATLAB Version 4 MAT-File.  The <CODE>matfile:load</CODE> procedure reads matrices from the
file and defines the <CODE>string-ci-&gt;symbol</CODE> for each matrix to its
corresponding array.  <CODE>matfile:load</CODE> returns a list of the symbols defined.
</DL>
<P>

<A NAME="Portable Image Files"></A>
<HR SIZE="6">
<A NAME="SEC193"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC192"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC194"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.8 Portable Image Files </H3>
<!--docid::SEC193::-->
<P>

<CODE>(require 'pnm)</CODE>
<A NAME="IDX1202"></A>
</P>
<P>

<A NAME="IDX1203"></A>
</P>
<DL>
<DT><U>Function:</U> <B>pnm:type-dimensions</B> <I>path</I>
<DD><P>

The string <VAR>path</VAR> must name a <EM>portable bitmap graphics</EM> file.
<A NAME="IDX1204"></A>
<CODE>pnm:type-dimensions</CODE> returns a list of 4 items:
<OL>
<LI>
A symbol describing the type of the file named by <VAR>path</VAR>.
<LI>
The image width in pixels.
<LI>
The image height in pixels.
<LI>
The maximum value of pixels assume in the file.
</OL>
<P>

The current set of file-type symbols is:
</P>
<DL COMPACT>
<DT>pbm
<DD><DT>pbm-raw
<DD><A NAME="IDX1205"></A>
<A NAME="IDX1206"></A>
Black-and-White image; pixel values are 0 or 1.
<DT>pgm
<DD><DT>pgm-raw
<DD><A NAME="IDX1207"></A>
<A NAME="IDX1208"></A>
Gray (monochrome) image; pixel values are from 0 to <VAR>maxval</VAR>
specified in file header.
<DT>ppm
<DD><DT>ppm-raw
<DD><A NAME="IDX1209"></A>
<A NAME="IDX1210"></A>
RGB (full color) image; red, green, and blue interleaved pixel values
are from 0 to <VAR>maxval</VAR>
</DL>
</DL>
<P>

<A NAME="IDX1211"></A>
</P>
<DL>
<DT><U>Function:</U> <B>pnm:image-file-&gt;array</B> <I>path array</I>
<DD><P>

Reads the <EM>portable bitmap graphics</EM> file named by <VAR>path</VAR> into
<A NAME="IDX1212"></A>
<VAR>array</VAR>.  <VAR>array</VAR> must be the correct size and type for
<VAR>path</VAR>.  <VAR>array</VAR> is returned.
</P>
<P>

<A NAME="IDX1213"></A>
<DT><U>Function:</U> <B>pnm:image-file-&gt;array</B> <I>path</I>
<DD></P>
<P>

<CODE>pnm:image-file-&gt;array</CODE> creates and returns an array with the
<EM>portable bitmap graphics</EM> file named by <VAR>path</VAR> read into it.
<A NAME="IDX1214"></A>
</P>
</DL>
<P>

<A NAME="IDX1215"></A>
</P>
<DL>
<DT><U>Function:</U> <B>pnm:array-write</B> <I>type array maxval path comment <small>...</small></I>
<DD><P>

Writes the contents of <VAR>array</VAR> to a <VAR>type</VAR> image file named <VAR>path</VAR>.  The file
will have pixel values between 0 and <VAR>maxval</VAR>, which must be compatible
with <VAR>type</VAR>.  For `<SAMP>pbm</SAMP>' files, <VAR>maxval</VAR> must be `<SAMP>1</SAMP>'.
<VAR>comment</VAR>s are included in the file header.
</P>
</DL>
<P>

<A NAME="Collections"></A>
<HR SIZE="6">
<A NAME="SEC194"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC193"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC195"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.9 Collections </H3>
<!--docid::SEC194::-->
<P>

<CODE>(require 'collect)</CODE>
<A NAME="IDX1216"></A>
</P>
<P>

Routines for managing collections.  Collections are aggregate data
structures supporting iteration over their elements, similar to the
Dylan(TM) language, but with a different interface.  They have
<EM>elements</EM> indexed by corresponding <EM>keys</EM>, although the keys
may be implicit (as with lists).
</P>
<P>

New types of collections may be defined as YASOS objects (see section <A HREF="slib_3.html#SEC40">3.8 Yasos</A>).
They must support the following operations:
</P>
<P>

<UL>
<LI>
<CODE>(collection? <VAR>self</VAR>)</CODE> (always returns <CODE>#t</CODE>);
<P>

</P>
<LI>
<CODE>(size <VAR>self</VAR>)</CODE> returns the number of elements in the collection;
<P>

</P>
<LI>
<CODE>(print <VAR>self</VAR> <VAR>port</VAR>)</CODE> is a specialized print operation
for the collection which prints a suitable representation on the given
<VAR>port</VAR> or returns it as a string if <VAR>port</VAR> is <CODE>#t</CODE>;
<P>

</P>
<LI>
<A NAME="IDX1217"></A>
<CODE>(gen-elts <VAR>self</VAR>)</CODE> returns a thunk which on successive
invocations yields elements of <VAR>self</VAR> in order or gives an error if
it is invoked more than <CODE>(size <VAR>self</VAR>)</CODE> times;
<P>

</P>
<LI>
<A NAME="IDX1218"></A>
<CODE>(gen-keys <VAR>self</VAR>)</CODE> is like <CODE>gen-elts</CODE>, but yields the
collection's keys in order.
</UL>
<P>

They might support specialized <CODE>for-each-key</CODE> and
<CODE>for-each-elt</CODE> operations.
</P>
<P>

<A NAME="IDX1219"></A>
</P>
<DL>
<DT><U>Function:</U> <B>collection?</B> <I>obj</I>
<DD>A predicate, true initially of lists, vectors and strings.  New sorts of
collections must answer <CODE>#t</CODE> to <CODE>collection?</CODE>.
</DL>
<P>

<A NAME="IDX1220"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>map-elts</B> <I>proc collection1 <small>...</small></I>
<DD><A NAME="IDX1221"></A>
<DT><U>Procedure:</U> <B>do-elts</B> <I>proc collection1 <small>...</small></I>
<DD><VAR>proc</VAR> is a procedure taking as many arguments as there are
<VAR>collections</VAR> (at least one).  The <VAR>collections</VAR> are iterated
over in their natural order and <VAR>proc</VAR> is applied to the elements
yielded by each iteration in turn.  The order in which the arguments are
supplied corresponds to te order in which the <VAR>collections</VAR> appear.
<CODE>do-elts</CODE> is used when only side-effects of <VAR>proc</VAR> are of
interest and its return value is unspecified.  <CODE>map-elts</CODE> returns a
collection (actually a vector) of the results of the applications of
<VAR>proc</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(map-elts + (list 1 2 3) (vector 1 2 3))
   => #(2 4 6)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1222"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>map-keys</B> <I>proc collection1 <small>...</small></I>
<DD><A NAME="IDX1223"></A>
<DT><U>Procedure:</U> <B>do-keys</B> <I>proc collection1 <small>...</small></I>
<DD>These are analogous to <CODE>map-elts</CODE> and <CODE>do-elts</CODE>, but each
iteration is over the <VAR>collections</VAR>' <EM>keys</EM> rather than their
elements.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(map-keys + (list 1 2 3) (vector 1 2 3))
   => #(0 2 4)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1224"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>for-each-key</B> <I>collection proc</I>
<DD><A NAME="IDX1225"></A>
<DT><U>Procedure:</U> <B>for-each-elt</B> <I>collection proc</I>
<DD>These are like <CODE>do-keys</CODE> and <CODE>do-elts</CODE> but only for a single
collection; they are potentially more efficient.
</DL>
<P>

<A NAME="IDX1226"></A>
</P>
<DL>
<DT><U>Function:</U> <B>reduce</B> <I>proc seed collection1 <small>...</small></I>
<DD>A generalization of the list-based <CODE>reduce-init</CODE>
(see section <A HREF="slib_7.html#SEC211">7.2.1.3 Lists as sequences</A>) to collections which will shadow the
list-based version if <CODE>(require 'collect)</CODE> follows
<A NAME="IDX1227"></A>
<CODE>(require 'common-list-functions)</CODE> (see section <A HREF="slib_7.html#SEC208">7.2.1 Common List Functions</A>).
<A NAME="IDX1228"></A>
<P>

Examples:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(reduce + 0 (vector 1 2 3))
   => 6
(reduce union '() '((a b c) (b c d) (d a)))
   => (c b d a).
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1229"></A>
</P>
<DL>
<DT><U>Function:</U> <B>any?</B> <I>pred collection1 <small>...</small></I>
<DD>A generalization of the list-based <CODE>some</CODE> (see section <A HREF="slib_7.html#SEC211">7.2.1.3 Lists as sequences</A>) to collections.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(any? odd? (list 2 3 4 5))
   => #t
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1230"></A>
</P>
<DL>
<DT><U>Function:</U> <B>every?</B> <I>pred collection1 <small>...</small></I>
<DD>A generalization of the list-based <CODE>every</CODE>
(see section <A HREF="slib_7.html#SEC211">7.2.1.3 Lists as sequences</A>) to collections.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(every? collection? '((1 2) #(1 2)))
   => #t
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1231"></A>
</P>
<DL>
<DT><U>Function:</U> <B>empty?</B> <I>collection</I>
<DD>Returns <CODE>#t</CODE> iff there are no elements in <VAR>collection</VAR>.
<P>

<CODE>(empty? <VAR>collection</VAR>) == (zero? (size <VAR>collection</VAR>))</CODE>
</P>
</DL>
<P>

<A NAME="IDX1232"></A>
</P>
<DL>
<DT><U>Function:</U> <B>size</B> <I>collection</I>
<DD>Returns the number of elements in <VAR>collection</VAR>.
</DL>
<P>

<A NAME="IDX1233"></A>
</P>
<DL>
<DT><U>Function:</U> <B>Setter</B> <I>list-ref</I>
<DD>See <A HREF="slib_3.html#SEC43">3.8.3 Setters</A> for a definition of <EM>setter</EM>.  N.B.
<CODE>(setter list-ref)</CODE> doesn't work properly for element 0 of a
list.
</DL>
<P>

Here is a sample collection: <CODE>simple-table</CODE> which is also a
<CODE>table</CODE>.
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define-predicate TABLE?)
(define-operation (LOOKUP table key failure-object))
(define-operation (ASSOCIATE! table key value)) ;; returns key
(define-operation (REMOVE! table key))          ;; returns value

(define (MAKE-SIMPLE-TABLE)
  (let ( (table (list)) )
    (object
     ;; table behaviors
     ((TABLE? self) #t)
     ((SIZE self) (size table))
     ((PRINT self port) (format port &quot;#&lt;SIMPLE-TABLE&gt;&quot;))
     ((LOOKUP self key failure-object)
      (cond
       ((assq key table) =&gt; cdr)
       (else failure-object)
       ))
     ((ASSOCIATE! self key value)
      (cond
       ((assq key table)
        =&gt; (lambda (bucket) (set-cdr! bucket value) key))
       (else
        (set! table (cons (cons key value) table))
        key)
       ))
     ((REMOVE! self key);; returns old value
      (cond
       ((null? table) (slib:error &quot;TABLE:REMOVE! Key not found: &quot; key))
       ((eq? key (caar table))
        (let ( (value (cdar table)) )
          (set! table (cdr table))
          value)
        )
       (else
        (let loop ( (last table) (this (cdr table)) )
          (cond
           ((null? this)
            (slib:error &quot;TABLE:REMOVE! Key not found: &quot; key))
           ((eq? key (caar this))
            (let ( (value (cdar this)) )
              (set-cdr! last (cdr this))
              value)
            )
           (else
            (loop (cdr last) (cdr this)))
           ) ) )
       ))
     ;; collection behaviors
     ((COLLECTION? self) #t)
     ((GEN-KEYS self) (collect:list-gen-elts (map car table)))
     ((GEN-ELTS self) (collect:list-gen-elts (map cdr table)))
     ((FOR-EACH-KEY self proc)
      (for-each (lambda (bucket) (proc (car bucket))) table)
      )
     ((FOR-EACH-ELT self proc)
      (for-each (lambda (bucket) (proc (cdr bucket))) table)
      ) ) ) )
</pre></td></tr></table><P>

<A NAME="Dynamic Data Type"></A>
<HR SIZE="6">
<A NAME="SEC195"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC194"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC196"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.10 Dynamic Data Type </H3>
<!--docid::SEC195::-->
<P>

<CODE>(require 'dynamic)</CODE>
<A NAME="IDX1234"></A>
</P>
<P>

<A NAME="IDX1235"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-dynamic</B> <I>obj</I>
<DD>Create and returns a new <EM>dynamic</EM> whose global value is <VAR>obj</VAR>.
</DL>
<P>

<A NAME="IDX1236"></A>
</P>
<DL>
<DT><U>Function:</U> <B>dynamic?</B> <I>obj</I>
<DD>Returns true if and only if <VAR>obj</VAR> is a dynamic.  No object
satisfying <CODE>dynamic?</CODE> satisfies any of the other standard type
predicates.
</DL>
<P>

<A NAME="IDX1237"></A>
</P>
<DL>
<DT><U>Function:</U> <B>dynamic-ref</B> <I>dyn</I>
<DD>Return the value of the given dynamic in the current dynamic
environment.
</DL>
<P>

<A NAME="IDX1238"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>dynamic-set!</B> <I>dyn obj</I>
<DD>Change the value of the given dynamic to <VAR>obj</VAR> in the current
dynamic environment.  The returned value is unspecified.
</DL>
<P>

<A NAME="IDX1239"></A>
</P>
<DL>
<DT><U>Function:</U> <B>call-with-dynamic-binding</B> <I>dyn obj thunk</I>
<DD>Invoke and return the value of the given thunk in a new, nested dynamic
environment in which the given dynamic has been bound to a new location
whose initial contents are the value <VAR>obj</VAR>.  This dynamic
environment has precisely the same extent as the invocation of the thunk
and is thus captured by continuations created within that invocation and
re-established by those continuations when they are invoked.
</DL>
<P>

The <CODE>dynamic-bind</CODE> macro is not implemented.
</P>
<P>

<A NAME="Hash Tables"></A>
<HR SIZE="6">
<A NAME="SEC196"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC195"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC197"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.11 Hash Tables </H3>
<!--docid::SEC196::-->
<P>

<CODE>(require 'hash-table)</CODE>
<A NAME="IDX1240"></A>
</P>
<P>

<A NAME="IDX1241"></A>
</P>
<DL>
<DT><U>Function:</U> <B>predicate-&gt;hash</B> <I>pred</I>
<DD><P>

Returns a hash function (like <CODE>hashq</CODE>, <CODE>hashv</CODE>, or
<CODE>hash</CODE>) corresponding to the equality predicate <VAR>pred</VAR>.
<VAR>pred</VAR> should be <CODE>eq?</CODE>, <CODE>eqv?</CODE>, <CODE>equal?</CODE>, <CODE>=</CODE>,
<CODE>char=?</CODE>, <CODE>char-ci=?</CODE>, <CODE>string=?</CODE>, or
<CODE>string-ci=?</CODE>.
</P>
</DL>
A hash table is a vector of association lists.
<P>

<A NAME="IDX1242"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-hash-table</B> <I>k</I>
<DD><P>

Returns a vector of <VAR>k</VAR> empty (association) lists.
</P>
</DL>
Hash table functions provide utilities for an associative database.
These functions take an equality predicate, <VAR>pred</VAR>, as an argument.
<VAR>pred</VAR> should be <CODE>eq?</CODE>, <CODE>eqv?</CODE>, <CODE>equal?</CODE>, <CODE>=</CODE>,
<CODE>char=?</CODE>, <CODE>char-ci=?</CODE>, <CODE>string=?</CODE>, or
<CODE>string-ci=?</CODE>.
<P>

<A NAME="IDX1243"></A>
</P>
<DL>
<DT><U>Function:</U> <B>predicate-&gt;hash-asso</B> <I>pred</I>
<DD><P>

Returns a hash association function of 2 arguments, <VAR>key</VAR> and
<VAR>hashtab</VAR>, corresponding to <VAR>pred</VAR>.  The returned function
returns a key-value pair whose key is <VAR>pred</VAR>-equal to its first
argument or <CODE>#f</CODE> if no key in <VAR>hashtab</VAR> is <VAR>pred</VAR>-equal to
the first argument.
</P>
</DL>
<P>

<A NAME="IDX1244"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hash-inquirer</B> <I>pred</I>
<DD><P>

Returns a procedure of 2 arguments, <VAR>hashtab</VAR> and <VAR>key</VAR>, which
returns the value associated with <VAR>key</VAR> in <VAR>hashtab</VAR> or
<CODE>#f</CODE> if <VAR>key</VAR> does not appear in <VAR>hashtab</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1245"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hash-associator</B> <I>pred</I>
<DD><P>

Returns a procedure of 3 arguments, <VAR>hashtab</VAR>, <VAR>key</VAR>, and
<VAR>value</VAR>, which modifies <VAR>hashtab</VAR> so that <VAR>key</VAR> and
<VAR>value</VAR> associated.  Any previous value associated with <VAR>key</VAR>
will be lost.
</P>
</DL>
<P>

<A NAME="IDX1246"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hash-remover</B> <I>pred</I>
<DD><P>

Returns a procedure of 2 arguments, <VAR>hashtab</VAR> and <VAR>key</VAR>, which
modifies <VAR>hashtab</VAR> so that the association whose key is <VAR>key</VAR> is
removed.
</P>
</DL>
<P>

<A NAME="IDX1247"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hash-map</B> <I>proc hash-table</I>
<DD><P>

Returns a new hash table formed by mapping <VAR>proc</VAR> over the
keys and values of <VAR>hash-table</VAR>.  <VAR>proc</VAR> must be a function of 2
arguments which returns the new value part.
</P>
</DL>
<P>

<A NAME="IDX1248"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hash-for-each</B> <I>proc hash-table</I>
<DD><P>

Applies <VAR>proc</VAR> to each pair of keys and values of <VAR>hash-table</VAR>.
<VAR>proc</VAR> must be a function of 2 arguments.  The returned value is
unspecified.
</P>
</DL>
<P>

<A NAME="IDX1249"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hash-rehasher</B> <I>pred</I>
<DD><P>

<CODE>hash-rehasher</CODE> accepts a hash table predicate and returns a function of two
arguments <VAR>hashtab</VAR> and <VAR>new-k</VAR> which is specialized for
that predicate.
</P>
<P>

This function is used for nondestrutively resizing a hash table.
<VAR>hashtab</VAR> should be an existing hash-table using <VAR>pred</VAR>, <VAR>new-k</VAR>
is the size of a new hash table to be returned.  The new hash table
will have all of the associations of the old hash table.
</P>
</DL>
<P>

<A NAME="Object"></A>
<HR SIZE="6">
<A NAME="SEC197"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC196"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC198"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.12 Macroless Object System </H3>
<!--docid::SEC197::-->
<P>

<CODE>(require 'object)</CODE>
<A NAME="IDX1250"></A>
</P>
<P>

This is the Macroless Object System written by Wade Humeniuk
(whumeniu@datap.ca).  Conceptual Tributes: <A HREF="slib_3.html#SEC40">3.8 Yasos</A>, MacScheme's
%object, CLOS, Lack of R4RS macros.
</P>
<P>

<HR SIZE="6">
<A NAME="SEC198"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC197"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC199"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.13 Concepts </H3>
<!--docid::SEC198::-->
<DL COMPACT>

<DT>OBJECT
<DD>An object is an ordered association-list (by <CODE>eq?</CODE>) of methods
(procedures).  Methods can be added (<CODE>make-method!</CODE>), deleted
(<CODE>unmake-method!</CODE>) and retrieved (<CODE>get-method</CODE>).  Objects may
inherit methods from other objects.  The object binds to the environment
it was created in, allowing closures to be used to hide private
procedures and data.
<P>

</P>
<DT>GENERIC-METHOD
<DD>A generic-method associates (in terms of <CODE>eq?</CODE>) object's method.
This allows scheme function style to be used for objects.  The calling
scheme for using a generic method is <CODE>(generic-method object param1
param2 ...)</CODE>.
<P>

</P>
<DT>METHOD
<DD>A method is a procedure that exists in the object.  To use a method
get-method must be called to look-up the method.  Generic methods
implement the get-method functionality.  Methods may be added to an
object associated with any scheme obj in terms of eq?
<P>

</P>
<DT>GENERIC-PREDICATE
<DD>A generic method that returns a boolean value for any scheme obj.
<P>

</P>
<DT>PREDICATE
<DD>A object's method asscociated with a generic-predicate. Returns
<CODE>#t</CODE>.
</DL>
<P>

<HR SIZE="6">
<A NAME="SEC199"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC198"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC200"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.14 Procedures </H3>
<!--docid::SEC199::-->
<P>

<A NAME="IDX1251"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-object</B> <I>ancestor <small>...</small></I>
<DD>Returns an object.  Current object implementation is a tagged vector.
<VAR>ancestor</VAR>s are optional and must be objects in terms of object?.
<VAR>ancestor</VAR>s methods are included in the object.  Multiple
<VAR>ancestor</VAR>s might associate the same generic-method with a method.
In this case the method of the <VAR>ancestor</VAR> first appearing in the
list is the one returned by <CODE>get-method</CODE>.
</DL>
<P>

<A NAME="IDX1252"></A>
</P>
<DL>
<DT><U>Function:</U> <B>object?</B> <I>obj</I>
<DD>Returns boolean value whether <VAR>obj</VAR> was created by make-object.
</DL>
<P>

<A NAME="IDX1253"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-generic-method</B> <I>exception-procedure</I>
<DD>Returns a procedure which be associated with an object's methods.  If
<VAR>exception-procedure</VAR> is specified then it is used to process
non-objects.
</DL>
<P>

<A NAME="IDX1254"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-generic-predicate</B>
<DD>Returns a boolean procedure for any scheme object.
</DL>
<P>

<A NAME="IDX1255"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-method!</B> <I>object generic-method method</I>
<DD>Associates <VAR>method</VAR> to the <VAR>generic-method</VAR> in the object.  The
<VAR>method</VAR> overrides any previous association with the
<VAR>generic-method</VAR> within the object.  Using <CODE>unmake-method!</CODE>
will restore the object's previous association with the
<VAR>generic-method</VAR>.  <VAR>method</VAR> must be a procedure.
</DL>
<P>

<A NAME="IDX1256"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-predicate!</B> <I>object generic-preciate</I>
<DD>Makes a predicate method associated with the <VAR>generic-predicate</VAR>.
</DL>
<P>

<A NAME="IDX1257"></A>
</P>
<DL>
<DT><U>Function:</U> <B>unmake-method!</B> <I>object generic-method</I>
<DD>Removes an object's association with a <VAR>generic-method</VAR> .
</DL>
<P>

<A NAME="IDX1258"></A>
</P>
<DL>
<DT><U>Function:</U> <B>get-method</B> <I>object generic-method</I>
<DD>Returns the object's method associated (if any) with the
<VAR>generic-method</VAR>.  If no associated method exists an error is
flagged.
</DL>
<P>

<HR SIZE="6">
<A NAME="SEC200"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC199"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC201"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.15 Examples </H3>
<!--docid::SEC200::-->
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'object)
<A NAME="IDX1259"></A>
(define instantiate (make-generic-method))

(define (make-instance-object . ancestors)
  (define self (apply make-object
                      (map (lambda (obj) (instantiate obj)) ancestors)))
  (make-method! self instantiate (lambda (self) self))
  self)

(define who (make-generic-method))
(define imigrate! (make-generic-method))
(define emigrate! (make-generic-method))
(define describe (make-generic-method))
(define name (make-generic-method))
(define address (make-generic-method))
(define members (make-generic-method))

(define society
  (let ()
    (define self (make-instance-object))
    (define population '())
    (make-method! self imigrate!
                  (lambda (new-person)
                    (if (not (eq? new-person self))
                        (set! population (cons new-person population)))))
    (make-method! self emigrate!
                  (lambda (person)
                    (if (not (eq? person self))
                        (set! population
                              (comlist:remove-if (lambda (member)
                                                   (eq? member person))
                                                 population)))))
    (make-method! self describe
                  (lambda (self)
                    (map (lambda (person) (describe person)) population)))
    (make-method! self who
                  (lambda (self) (map (lambda (person) (name person))
                                      population)))
    (make-method! self members (lambda (self) population))
    self))

(define (make-person %name %address)
  (define self (make-instance-object society))
  (make-method! self name (lambda (self) %name))
  (make-method! self address (lambda (self) %address))
  (make-method! self who (lambda (self) (name self)))
  (make-method! self instantiate
                (lambda (self)
                  (make-person (string-append (name self) &quot;-son-of&quot;)
                               %address)))
  (make-method! self describe
                (lambda (self) (list (name self) (address self))))
  (imigrate! self)
  self)
</pre></td></tr></table><P>

<HR SIZE="6">
<A NAME="SEC201"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC200"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC202"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.1.15.1 Inverter Documentation </H4>
<!--docid::SEC201::-->
Inheritance:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>        &lt;inverter&gt;::(&lt;number&gt; &lt;description&gt;)
</pre></td></tr></table>Generic-methods
<TABLE><tr><td>&nbsp;</td><td class=example><pre>        &lt;inverter&gt;::value      => &lt;number&gt;::value
        &lt;inverter&gt;::set-value! => &lt;number&gt;::set-value!
        &lt;inverter&gt;::describe   => &lt;description&gt;::describe
        &lt;inverter&gt;::help
        &lt;inverter&gt;::invert
        &lt;inverter&gt;::inverter?
</pre></td></tr></table><P>

<HR SIZE="6">
<A NAME="SEC202"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC201"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC203"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.1.15.2 Number Documention </H4>
<!--docid::SEC202::-->
Inheritance
<TABLE><tr><td>&nbsp;</td><td class=example><pre>        &lt;number&gt;::()
</pre></td></tr></table>Slots
<TABLE><tr><td>&nbsp;</td><td class=example><pre>        &lt;number&gt;::&lt;x&gt;
</pre></td></tr></table>Generic Methods
<TABLE><tr><td>&nbsp;</td><td class=example><pre>        &lt;number&gt;::value
        &lt;number&gt;::set-value!
</pre></td></tr></table><P>

<HR SIZE="6">
<A NAME="SEC203"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC202"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC204"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.1.15.3 Inverter code </H4>
<!--docid::SEC203::-->
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'object)
<A NAME="IDX1260"></A>
(define value (make-generic-method (lambda (val) val)))
(define set-value! (make-generic-method))
(define invert (make-generic-method
                (lambda (val)
                  (if (number? val)
                      (/ 1 val)
                      (error &quot;Method not supported:&quot; val)))))
(define noop (make-generic-method))
(define inverter? (make-generic-predicate))
(define describe (make-generic-method))
(define help (make-generic-method))

(define (make-number x)
  (define self (make-object))
  (make-method! self value (lambda (this) x))
  (make-method! self set-value!
                (lambda (this new-value) (set! x new-value)))
  self)

(define (make-description str)
  (define self (make-object))
  (make-method! self describe (lambda (this) str))
  (make-method! self help (lambda (this) &quot;Help not available&quot;))
  self)

(define (make-inverter)
  (let* ((self (make-object
                (make-number 1)
                (make-description &quot;A number which can be inverted&quot;)))
         (&lt;value&gt; (get-method self value)))
    (make-method! self invert (lambda (self) (/ 1 (&lt;value&gt; self))))
    (make-predicate! self inverter?)
    (unmake-method! self help)
    (make-method! self help
                  (lambda (self)
                    (display &quot;Inverter Methods:&quot;) (newline)
                    (display &quot;  (value inverter) ==&gt; n&quot;) (newline)))
    self))

;;;; Try it out

(define invert! (make-generic-method))

(define x (make-inverter))

(make-method! x invert! (lambda (x) (set-value! x (/ 1 (value x)))))

(value x)                       => 1
(set-value! x 33)               => undefined
(invert! x)                     => undefined
(value x)                       => 1/33

(unmake-method! x invert!)      => undefined

(invert! x)                     error-->  ERROR: Method not supported: x
</pre></td></tr></table><P>

<A NAME="Priority Queues"></A>
<HR SIZE="6">
<A NAME="SEC204"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC203"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC205"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.16 Priority Queues </H3>
<!--docid::SEC204::-->
<P>

<CODE>(require 'priority-queue)</CODE>
<A NAME="IDX1261"></A>
</P>
<P>

This algorithm for priority queues is due to
<CITE>Introduction to Algorithms</CITE>
by T. Cormen, C. Leiserson, R. Rivest.
1989 MIT Press.
</P>
<P>

<A NAME="IDX1262"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-heap</B> <I>pred&lt;?</I>
<DD><P>

Returns a binary heap suitable which can be used for priority queue
operations.
</P>
</DL>
<P>

<A NAME="IDX1263"></A>
</P>
<DL>
<DT><U>Function:</U> <B>heap-length</B> <I>heap</I>
<DD><P>

Returns the number of elements in <VAR>heap</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1264"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>heap-insert!</B> <I>heap item</I>
<DD><P>

Inserts <VAR>item</VAR> into <VAR>heap</VAR>.  <VAR>item</VAR> can be inserted multiple
times.  The value returned is unspecified.
</P>
</DL>
<P>

<A NAME="IDX1265"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>heap-extract-max!</B> <I>heap</I>
<DD><P>

Returns the item which is larger than all others according to the
<VAR>pred&lt;?</VAR> argument to <CODE>make-heap</CODE>.  If there are no items in
<VAR>heap</VAR>, an error is signaled.
</P>
</DL>
<P>

<A NAME="Queues"></A>
<HR SIZE="6">
<A NAME="SEC205"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC204"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC206"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.17 Queues </H3>
<!--docid::SEC205::-->
<P>

<CODE>(require 'queue)</CODE>
<A NAME="IDX1266"></A>
</P>
<P>

A <EM>queue</EM> is a list where elements can be added to both the front
<A NAME="IDX1267"></A>
and rear, and removed from the front (i.e., they are what are often
called <EM>dequeues</EM>).  A queue may also be used like a stack.
<A NAME="IDX1268"></A>
</P>
<P>

<A NAME="IDX1269"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-queue</B>
<DD><P>

Returns a new, empty queue.
</P>
</DL>
<P>

<A NAME="IDX1270"></A>
</P>
<DL>
<DT><U>Function:</U> <B>queue?</B> <I>obj</I>
<DD><P>

Returns <CODE>#t</CODE> if <VAR>obj</VAR> is a queue.
</P>
</DL>
<P>

<A NAME="IDX1271"></A>
</P>
<DL>
<DT><U>Function:</U> <B>queue-empty?</B> <I>q</I>
<DD><P>

Returns <CODE>#t</CODE> if the queue <VAR>q</VAR> is empty.
</P>
</DL>
<P>

<A NAME="IDX1272"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>queue-push!</B> <I>q datum</I>
<DD><P>

Adds <VAR>datum</VAR> to the front of queue <VAR>q</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1273"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>enqueue!</B> <I>q datum</I>
<DD><P>

Adds <VAR>datum</VAR> to the rear of queue <VAR>q</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1274"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>dequeue!</B> <I>q</I>
<DD><P>

<A NAME="IDX1275"></A>
<DT><U>Procedure:</U> <B>queue-pop!</B> <I>q</I>
<DD>Both of these procedures remove and return the datum at the front of
the queue.  <CODE>queue-pop!</CODE> is used to suggest that the queue is
being used like a stack.
</P>
</DL>
All of the following functions raise an error if the queue <VAR>q</VAR>
is empty.
<P>

<A NAME="IDX1276"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>dequeue-all!</B> <I>q</I>
<DD><P>

Removes and returns (the list) of all contents of queue <VAR>q</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1277"></A>
</P>
<DL>
<DT><U>Function:</U> <B>queue-front</B> <I>q</I>
<DD><P>

Returns the datum at the front of the queue <VAR>q</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1278"></A>
</P>
<DL>
<DT><U>Function:</U> <B>queue-rear</B> <I>q</I>
<DD><P>

Returns the datum at the rear of the queue <VAR>q</VAR>.
</P>
</DL>
<P>

<A NAME="Records"></A>
<HR SIZE="6">
<A NAME="SEC206"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC205"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC184"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.1.18 Records </H3>
<!--docid::SEC206::-->
<P>

<CODE>(require 'record)</CODE>
<A NAME="IDX1279"></A>
</P>
<P>

The Record package provides a facility for user to define their own
record data types.
</P>
<P>

<A NAME="IDX1280"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-record-type</B> <I>type-name field-names</I>
<DD>Returns a <EM>record-type descriptor</EM>, a value representing a new data
type disjoint from all others.  The <VAR>type-name</VAR> argument must be a
string, but is only used for debugging purposes (such as the printed
representation of a record of the new type).  The <VAR>field-names</VAR>
argument is a list of symbols naming the <EM>fields</EM> of a record of the
new type.  It is an error if the list contains any duplicates.  It is
unspecified how record-type descriptors are represented.
</DL>
<P>

<A NAME="IDX1281"></A>
</P>
<DL>
<DT><U>Function:</U> <B>record-constructor</B> <I>rtd [field-names]</I>
<DD>Returns a procedure for constructing new members of the type represented
by <VAR>rtd</VAR>.  The returned procedure accepts exactly as many arguments
as there are symbols in the given list, <VAR>field-names</VAR>; these are
used, in order, as the initial values of those fields in a new record,
which is returned by the constructor procedure.  The values of any
fields not named in that list are unspecified.  The <VAR>field-names</VAR>
argument defaults to the list of field names in the call to
<CODE>make-record-type</CODE> that created the type represented by <VAR>rtd</VAR>;
if the <VAR>field-names</VAR> argument is provided, it is an error if it
contains any duplicates or any symbols not in the default list.
</DL>
<P>

<A NAME="IDX1282"></A>
</P>
<DL>
<DT><U>Function:</U> <B>record-predicate</B> <I>rtd</I>
<DD>Returns a procedure for testing membership in the type represented by
<VAR>rtd</VAR>.  The returned procedure accepts exactly one argument and
returns a true value if the argument is a member of the indicated record
type; it returns a false value otherwise.
</DL>
<P>

<A NAME="IDX1283"></A>
</P>
<DL>
<DT><U>Function:</U> <B>record-accessor</B> <I>rtd field-name</I>
<DD>Returns a procedure for reading the value of a particular field of a
member of the type represented by <VAR>rtd</VAR>.  The returned procedure
accepts exactly one argument which must be a record of the appropriate
type; it returns the current value of the field named by the symbol
<VAR>field-name</VAR> in that record.  The symbol <VAR>field-name</VAR> must be a
member of the list of field-names in the call to <CODE>make-record-type</CODE>
that created the type represented by <VAR>rtd</VAR>.
</DL>
<P>

<A NAME="IDX1284"></A>
</P>
<DL>
<DT><U>Function:</U> <B>record-modifier</B> <I>rtd field-name</I>
<DD>Returns a procedure for writing the value of a particular field of a
member of the type represented by <VAR>rtd</VAR>.  The returned procedure
accepts exactly two arguments: first, a record of the appropriate type,
and second, an arbitrary Scheme value; it modifies the field named by
the symbol <VAR>field-name</VAR> in that record to contain the given value.
The returned value of the modifier procedure is unspecified.  The symbol
<VAR>field-name</VAR> must be a member of the list of field-names in the call
to <CODE>make-record-type</CODE> that created the type represented by
<VAR>rtd</VAR>.
</DL>
<P>

In May of 1996, as a product of discussion on the <CODE>rrrs-authors</CODE>
mailing list, I rewrote `<TT>record.scm</TT>' to portably implement type
disjointness for record data types.
</P>
<P>

As long as an implementation's procedures are opaque and the
<CODE>record</CODE> code is loaded before other programs, this will give
disjoint record types which are unforgeable and incorruptible by R4RS
procedures.
</P>
<P>

As a consequence, the procedures <CODE>record?</CODE>,
<CODE>record-type-descriptor</CODE>, <CODE>record-type-name</CODE>.and
<CODE>record-type-field-names</CODE> are no longer supported.
</P>
<P>

<A NAME="Sorting and Searching"></A>
<HR SIZE="6">
<A NAME="SEC207"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC206"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC208"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 7.2 Sorting and Searching </H2>
<!--docid::SEC207::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC208">7.2.1 Common List Functions</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'common-list-functions</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC214">7.2.2 Tree operations</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'tree</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC215">7.2.3 Chapter Ordering</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'chapter-order</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC216">7.2.4 Sorting</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'sort</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC217">7.2.5 Topological Sort</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Keep your socks on.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC218">7.2.6 Hashing</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'hash</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC219">7.2.7 Space-Filling Curves</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'hilbert and 'sierpinski</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC222">7.2.8 Soundex</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Dimension Reduction of Last Names</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC223">7.2.9 String Search</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Also Search from a Port.</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC224">7.2.10 Sequence Comparison</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'diff and longest-common-subsequence</TD></TR>
</TABLE>
<P>

<A NAME="Common List Functions"></A>
<HR SIZE="6">
<A NAME="SEC208"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC209"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.1 Common List Functions </H3>
<!--docid::SEC208::-->
<P>

<CODE>(require 'common-list-functions)</CODE>
<A NAME="IDX1285"></A>
</P>
<P>

The procedures below follow the Common LISP equivalents apart from
optional arguments in some cases.
</P>
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC209">7.2.1.1 List construction</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC210">7.2.1.2 Lists as sets</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC211">7.2.1.3 Lists as sequences</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC212">7.2.1.4 Destructive list operations</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC213">7.2.1.5 Non-List functions</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<P>

<A NAME="List construction"></A>
<HR SIZE="6">
<A NAME="SEC209"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC208"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC210"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC208"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.2.1.1 List construction </H4>
<!--docid::SEC209::-->
<P>

<A NAME="IDX1286"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-list</B> <I>k</I>
<DD><A NAME="IDX1287"></A>
<DT><U>Function:</U> <B>make-list</B> <I>k init</I>
<DD><CODE>make-list</CODE> creates and returns a list of <VAR>k</VAR> elements.  If
<VAR>init</VAR> is included, all elements in the list are initialized to
<VAR>init</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(make-list 3)
   => (#&lt;unspecified&gt; #&lt;unspecified&gt; #&lt;unspecified&gt;)
(make-list 5 'foo)
   => (foo foo foo foo foo)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1288"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list*</B> <I>obj1 obj2 <small>...</small></I>
<DD>Works like <CODE>list</CODE> except that the cdr of the last pair is the last
argument unless there is only one argument, when the result is just that
argument.  Sometimes called <CODE>cons*</CODE>.  E.g.:
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(list* 1)
   => 1
(list* 1 2 3)
   => (1 2 . 3)
(list* 1 2 '(3 4))
   => (1 2 3 4)
(list* <VAR>args</VAR> '())
   == (list <VAR>args</VAR>)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1289"></A>
</P>
<DL>
<DT><U>Function:</U> <B>copy-list</B> <I>lst</I>
<DD><CODE>copy-list</CODE> makes a copy of <VAR>lst</VAR> using new pairs and returns
it. Only the top level of the list is copied, i.e., pairs forming
elements of the copied list remain <CODE>eq?</CODE> to the corresponding
elements of the original; the copy is, however, not <CODE>eq?</CODE> to the
original, but is <CODE>equal?</CODE> to it.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(copy-list '(foo foo foo))
   => (foo foo foo)
(define q '(foo bar baz bang))
(define p q)
(eq? p q)
   => #t
(define r (copy-list q))
(eq? q r)
   => #f
(equal? q r)
   => #t
(define bar '(bar))
(eq? bar (car (copy-list (list bar 'foo))))
=> #t
</pre></td></tr></table></DL>
<P>

<A NAME="Lists as sets"></A>
<HR SIZE="6">
<A NAME="SEC210"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC209"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC211"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC208"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.2.1.2 Lists as sets </H4>
<!--docid::SEC210::-->
<P>

<CODE>eqv?</CODE> is used to test for membership by procedures which treat
lists as sets.
</P>
<P>

<A NAME="IDX1290"></A>
</P>
<DL>
<DT><U>Function:</U> <B>adjoin</B> <I>e l</I>
<DD><CODE>adjoin</CODE> returns the adjoint of the element <VAR>e</VAR> and the list
<VAR>l</VAR>.  That is, if <VAR>e</VAR> is in <VAR>l</VAR>, <CODE>adjoin</CODE> returns
<VAR>l</VAR>, otherwise, it returns <CODE>(cons <VAR>e</VAR> <VAR>l</VAR>)</CODE>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(adjoin 'baz '(bar baz bang))
   => (bar baz bang)
(adjoin 'foo '(bar baz bang))
   => (foo bar baz bang)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1291"></A>
</P>
<DL>
<DT><U>Function:</U> <B>union</B> <I>l1 l2</I>
<DD><CODE>union</CODE> returns a list of all elements that are in <VAR>l1</VAR> or
<VAR>l2</VAR>.  Duplicates between <VAR>l1</VAR> and <VAR>l2</VAR> are culled.
Duplicates within <VAR>l1</VAR> or within <VAR>l2</VAR> may or may not be
removed.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(union '(1 2 3 4) '(5 6 7 8))
   => (1 2 3 4 5 6 7 8)
(union '(0 1 2 3 4) '(3 4 5 6))
   => (5 6 0 1 2 3 4)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1292"></A>
</P>
<DL>
<DT><U>Function:</U> <B>intersection</B> <I>l1 l2</I>
<DD><CODE>intersection</CODE> returns a list of all elements that are in both
<VAR>l1</VAR> and <VAR>l2</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(intersection '(1 2 3 4) '(3 4 5 6))
   => (3 4)
(intersection '(1 2 3 4) '(5 6 7 8))
   => ()
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1293"></A>
</P>
<DL>
<DT><U>Function:</U> <B>set-difference</B> <I>l1 l2</I>
<DD><CODE>set-difference</CODE> returns a list of all elements that are in
<VAR>l1</VAR> but not in <VAR>l2</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set-difference '(1 2 3 4) '(3 4 5 6))
   => (1 2)
(set-difference '(1 2 3 4) '(1 2 3 4 5 6))
   => ()
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1294"></A>
</P>
<DL>
<DT><U>Function:</U> <B>subset?</B> <I>list1 list2</I>
<DD>Returns <CODE>#t</CODE> if every element of <VAR>list1</VAR> is <CODE>eqv?</CODE> an
element of <VAR>list2</VAR>; otherwise returns <CODE>#f</CODE>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(subset? '(1 2 3 4) '(3 4 5 6))
   => #f
(subset? '(1 2 3 4) '(6 5 4 3 2 1 0))
   => #t
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1295"></A>
</P>
<DL>
<DT><U>Function:</U> <B>member-if</B> <I>pred lst</I>
<DD><CODE>member-if</CODE> returns the list headed by the first element of
<VAR>lst</VAR> to satisfy <CODE>(<VAR>pred</VAR> <VAR>element</VAR>)</CODE>.
<CODE>Member-if</CODE> returns <CODE>#f</CODE> if <VAR>pred</VAR> returns <CODE>#f</CODE> for
every <VAR>element</VAR> in <VAR>lst</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(member-if vector? '(a 2 b 4))
   => #f
(member-if number? '(a 2 b 4))
   => (2 b 4)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1296"></A>
</P>
<DL>
<DT><U>Function:</U> <B>some</B> <I>pred lst1 lst2 <small>...</small></I>
<DD><VAR>pred</VAR> is a boolean function of as many arguments as there are list
arguments to <CODE>some</CODE> i.e., <VAR>lst</VAR> plus any optional arguments.
<VAR>pred</VAR> is applied to successive elements of the list arguments in
order.  <CODE>some</CODE> returns <CODE>#t</CODE> as soon as one of these
applications returns <CODE>#t</CODE>, and is <CODE>#f</CODE> if none returns
<CODE>#t</CODE>.  All the lists should have the same length.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(some odd? '(1 2 3 4))
   => #t

(some odd? '(2 4 6 8))
   => #f

(some &gt; '(1 3) '(2 4))
   => #f
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1297"></A>
</P>
<DL>
<DT><U>Function:</U> <B>every</B> <I>pred lst1 lst2 <small>...</small></I>
<DD><CODE>every</CODE> is analogous to <CODE>some</CODE> except it returns <CODE>#t</CODE> if
every application of <VAR>pred</VAR> is <CODE>#t</CODE> and <CODE>#f</CODE>
otherwise.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(every even? '(1 2 3 4))
   => #f

(every even? '(2 4 6 8))
   => #t

(every &gt; '(2 3) '(1 4))
   => #f
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1298"></A>
</P>
<DL>
<DT><U>Function:</U> <B>notany</B> <I>pred lst1 <small>...</small></I>
<DD><CODE>notany</CODE> is analogous to <CODE>some</CODE> but returns <CODE>#t</CODE> if no
application of <VAR>pred</VAR> returns <CODE>#t</CODE> or <CODE>#f</CODE> as soon as any
one does.
</DL>
<P>

<A NAME="IDX1299"></A>
</P>
<DL>
<DT><U>Function:</U> <B>notevery</B> <I>pred lst1 <small>...</small></I>
<DD><CODE>notevery</CODE> is analogous to <CODE>some</CODE> but returns <CODE>#t</CODE> as soon
as an application of <VAR>pred</VAR> returns <CODE>#f</CODE>, and <CODE>#f</CODE>
otherwise.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(notevery even? '(1 2 3 4))
   => #t

(notevery even? '(2 4 6 8))
   => #f
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1300"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-of??</B> <I>predicate</I>
<DD>Returns a predicate which returns true if its argument is a list every
element of which satisfies <VAR>predicate</VAR>.
<P>

<A NAME="IDX1301"></A>
<DT><U>Function:</U> <B>list-of??</B> <I>predicate low-bound high-bound</I>
<DD><VAR>low-bound</VAR> and <VAR>high-bound</VAR> are non-negative integers.
<CODE>list-of??</CODE> returns a predicate which returns true if its argument
is a list of length between <VAR>low-bound</VAR> and <VAR>high-bound</VAR>
(inclusive); every element of which satisfies <VAR>predicate</VAR>.
</P>
<P>

<A NAME="IDX1302"></A>
<DT><U>Function:</U> <B>list-of??</B> <I>predicate bound</I>
<DD><VAR>bound</VAR> is an integer.  If <VAR>bound</VAR> is negative, <CODE>list-of??</CODE>
returns a predicate which returns true if its argument is a list of
length greater than <CODE>(- <VAR>bound</VAR>)</CODE>; every element of which
satisfies <VAR>predicate</VAR>.  Otherwise, <CODE>list-of??</CODE>  returns a
predicate which returns true if its argument is a list of length less
than or equal to <VAR>bound</VAR>; every element of which satisfies
<VAR>predicate</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1303"></A>
</P>
<DL>
<DT><U>Function:</U> <B>find-if</B> <I>pred lst</I>
<DD><CODE>find-if</CODE> searches for the first <VAR>element</VAR> in <VAR>lst</VAR> such
that <CODE>(<VAR>pred</VAR> <VAR>element</VAR>)</CODE> returns <CODE>#t</CODE>.  If it finds
any such <VAR>element</VAR> in <VAR>lst</VAR>, <VAR>element</VAR> is returned.
Otherwise, <CODE>#f</CODE> is returned.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(find-if number? '(foo 1 bar 2))
   => 1

(find-if number? '(foo bar baz bang))
   => #f

(find-if symbol? '(1 2 foo bar))
   => foo
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1304"></A>
</P>
<DL>
<DT><U>Function:</U> <B>remove</B> <I>elt lst</I>
<DD><CODE>remove</CODE> removes all occurrences of <VAR>elt</VAR> from <VAR>lst</VAR> using
<CODE>eqv?</CODE> to test for equality and returns everything that's left.
N.B.: other implementations (Chez, Scheme-&gt;C and T, at least) use
<CODE>equal?</CODE> as the equality test.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(remove 1 '(1 2 1 3 1 4 1 5))
   => (2 3 4 5)

(remove 'foo '(bar baz bang))
   => (bar baz bang)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1305"></A>
</P>
<DL>
<DT><U>Function:</U> <B>remove-if</B> <I>pred lst</I>
<DD><CODE>remove-if</CODE> removes all <VAR>element</VAR>s from <VAR>lst</VAR> where
<CODE>(<VAR>pred</VAR> <VAR>element</VAR>)</CODE> is <CODE>#t</CODE> and returns everything
that's left.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(remove-if number? '(1 2 3 4))
   => ()

(remove-if even? '(1 2 3 4 5 6 7 8))
   => (1 3 5 7)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1306"></A>
</P>
<DL>
<DT><U>Function:</U> <B>remove-if-not</B> <I>pred lst</I>
<DD><CODE>remove-if-not</CODE> removes all <VAR>element</VAR>s from <VAR>lst</VAR> for which
<CODE>(<VAR>pred</VAR> <VAR>element</VAR>)</CODE> is <CODE>#f</CODE> and returns everything that's
left.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(remove-if-not number? '(foo bar baz))
   => ()
(remove-if-not odd? '(1 2 3 4 5 6 7 8))
   => (1 3 5 7)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1307"></A>
</P>
<DL>
<DT><U>Function:</U> <B>has-duplicates?</B> <I>lst</I>
<DD>returns <CODE>#t</CODE> if 2 members of <VAR>lst</VAR> are <CODE>equal?</CODE>, <CODE>#f</CODE>
otherwise.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(has-duplicates? '(1 2 3 4))
   => #f

(has-duplicates? '(2 4 3 4))
   => #t
</pre></td></tr></table></DL>
<P>

The procedure <CODE>remove-duplicates</CODE> uses <CODE>member</CODE> (rather than
<CODE>memv</CODE>).
</P>
<P>

<A NAME="IDX1308"></A>
</P>
<DL>
<DT><U>Function:</U> <B>remove-duplicates</B> <I>lst</I>
<DD>returns a copy of <VAR>lst</VAR> with its duplicate members removed.
Elements are considered duplicate if they are <CODE>equal?</CODE>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(remove-duplicates '(1 2 3 4))
   => (1 2 3 4)

(remove-duplicates '(2 4 3 4))
   => (2 4 3)
</pre></td></tr></table></DL>
<P>

<A NAME="Lists as sequences"></A>
<HR SIZE="6">
<A NAME="SEC211"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC210"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC212"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC208"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.2.1.3 Lists as sequences </H4>
<!--docid::SEC211::-->
<P>

<A NAME="IDX1309"></A>
</P>
<DL>
<DT><U>Function:</U> <B>position</B> <I>obj lst</I>
<DD><CODE>position</CODE> returns the 0-based position of <VAR>obj</VAR> in <VAR>lst</VAR>,
or <CODE>#f</CODE> if <VAR>obj</VAR> does not occur in <VAR>lst</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(position 'foo '(foo bar baz bang))
   => 0
(position 'baz '(foo bar baz bang))
   => 2
(position 'oops '(foo bar baz bang))
   => #f
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1310"></A>
</P>
<DL>
<DT><U>Function:</U> <B>reduce</B> <I>p lst</I>
<DD><CODE>reduce</CODE> combines all the elements of a sequence using a binary
operation (the combination is left-associative).  For example, using
<CODE>+</CODE>, one can add up all the elements.  <CODE>reduce</CODE> allows you to
apply a function which accepts only two arguments to more than 2
objects.  Functional programmers usually refer to this as <EM>foldl</EM>.
<CODE>collect:reduce</CODE> (see section <A HREF="slib_7.html#SEC194">7.1.9 Collections</A>) provides a version of
<CODE>collect</CODE> generalized to collections.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(reduce + '(1 2 3 4))
   => 10
(define (bad-sum . l) (reduce + l))
(bad-sum 1 2 3 4)
   == (reduce + (1 2 3 4))
   == (+ (+ (+ 1 2) 3) 4)
=> 10
(bad-sum)
   == (reduce + ())
   => ()
(reduce string-append '(&quot;hello&quot; &quot;cruel&quot; &quot;world&quot;))
   == (string-append (string-append &quot;hello&quot; &quot;cruel&quot;) &quot;world&quot;)
   => &quot;hellocruelworld&quot;
(reduce anything '())
   => ()
(reduce anything '(x))
   => x
</pre></td></tr></table><P>

What follows is a rather non-standard implementation of <CODE>reverse</CODE>
in terms of <CODE>reduce</CODE> and a combinator elsewhere called
<EM>C</EM>.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>;;; Contributed by Jussi Piitulainen (jpiitula @ ling.helsinki.fi)

(define commute
  (lambda (f)
    (lambda (x y)
      (f y x))))

(define reverse
  (lambda (args)
    (reduce-init (commute cons) '() args)))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1311"></A>
</P>
<DL>
<DT><U>Function:</U> <B>reduce-init</B> <I>p init lst</I>
<DD><CODE>reduce-init</CODE> is the same as reduce, except that it implicitly
inserts <VAR>init</VAR> at the start of the list.  <CODE>reduce-init</CODE> is
preferred if you want to handle the null list, the one-element, and
lists with two or more elements consistently.  It is common to use the
operator's idempotent as the initializer.  Functional programmers
usually call this <EM>foldl</EM>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define (sum . l) (reduce-init + 0 l))
(sum 1 2 3 4)
   == (reduce-init + 0 (1 2 3 4))
   == (+ (+ (+ (+ 0 1) 2) 3) 4)
   => 10
(sum)
   == (reduce-init + 0 '())
   => 0

(reduce-init string-append &quot;@&quot; '(&quot;hello&quot; &quot;cruel&quot; &quot;world&quot;))
==
(string-append (string-append (string-append &quot;@&quot; &quot;hello&quot;)
                               &quot;cruel&quot;)
               &quot;world&quot;)
=> &quot;@hellocruelworld&quot;
</pre></td></tr></table><P>

Given a differentiation of 2 arguments, <CODE>diff</CODE>, the following will
differentiate by any number of variables.
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define (diff* exp . vars)
  (reduce-init diff exp vars))
</pre></td></tr></table><P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>;;; Real-world example:  Insertion sort using reduce-init.

(define (insert l item)
  (if (null? l)
      (list item)
      (if (&lt; (car l) item)
          (cons (car l) (insert (cdr l) item))
          (cons item l))))
(define (insertion-sort l) (reduce-init insert '() l))

(insertion-sort '(3 1 4 1 5)
   == (reduce-init insert () (3 1 4 1 5))
   == (insert (insert (insert (insert (insert () 3) 1) 4) 1) 5)
   == (insert (insert (insert (insert (3)) 1) 4) 1) 5)
   == (insert (insert (insert (1 3) 4) 1) 5)
   == (insert (insert (1 3 4) 1) 5)
   == (insert (1 1 3 4) 5)
   => (1 1 3 4 5)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1312"></A>
</P>
<DL>
<DT><U>Function:</U> <B>last</B> <I>lst n</I>
<DD><CODE>last</CODE> returns the last <VAR>n</VAR> elements of <VAR>lst</VAR>.  <VAR>n</VAR>
must be a non-negative integer.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(last '(foo bar baz bang) 2)
   => (baz bang)
(last '(1 2 3) 0)
   => 0
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1313"></A>
</P>
<DL>
<DT><U>Function:</U> <B>butlast</B> <I>lst n</I>
<DD><CODE>butlast</CODE> returns all but the last <VAR>n</VAR> elements of
<VAR>lst</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(butlast '(a b c d) 3)
   => (a)
(butlast '(a b c d) 4)
   => ()
</pre></td></tr></table></DL>
<P>

<CODE>last</CODE> and <CODE>butlast</CODE> split a list into two parts when given
identical arugments.
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(last '(a b c d e) 2)
   => (d e)
(butlast '(a b c d e) 2)
   => (a b c)
</pre></td></tr></table><P>

<A NAME="IDX1314"></A>
</P>
<DL>
<DT><U>Function:</U> <B>nthcdr</B> <I>n lst</I>
<DD><CODE>nthcdr</CODE> takes <VAR>n</VAR> <CODE>cdr</CODE>s of <VAR>lst</VAR> and returns the
result.  Thus <CODE>(nthcdr 3 <VAR>lst</VAR>)</CODE> == <CODE>(cdddr
<VAR>lst</VAR>)</CODE>
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(nthcdr 2 '(a b c d))
   => (c d)
(nthcdr 0 '(a b c d))
   => (a b c d)
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1315"></A>
</P>
<DL>
<DT><U>Function:</U> <B>butnthcdr</B> <I>n lst</I>
<DD><CODE>butnthcdr</CODE> returns all but the nthcdr <VAR>n</VAR> elements of
<VAR>lst</VAR>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(butnthcdr 3 '(a b c d))
   => (a b c)
(butnthcdr 4 '(a b c d))
   => (a b c d)
</pre></td></tr></table></DL>
<P>

<CODE>nthcdr</CODE> and <CODE>butnthcdr</CODE> split a list into two parts when
given identical arugments.
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(nthcdr 2 '(a b c d e))
   => (c d e)
(butnthcdr 2 '(a b c d e))
   => (a b)
</pre></td></tr></table><P>

<A NAME="Destructive list operations"></A>
<HR SIZE="6">
<A NAME="SEC212"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC211"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC213"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC208"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.2.1.4 Destructive list operations </H4>
<!--docid::SEC212::-->
<P>

These procedures may mutate the list they operate on, but any such
mutation is undefined.
</P>
<P>

<A NAME="IDX1316"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>nconc</B> <I>args</I>
<DD><CODE>nconc</CODE> destructively concatenates its arguments.  (Compare this
with <CODE>append</CODE>, which copies arguments rather than destroying them.)
Sometimes called <CODE>append!</CODE> (see section <A HREF="slib_7.html#SEC239">7.4.4 Rev2 Procedures</A>).
<P>

Example:  You want to find the subsets of a set.  Here's the obvious way:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define (subsets set)
  (if (null? set)
      '(())
      (append (map (lambda (sub) (cons (car set) sub))
                   (subsets (cdr set)))
              (subsets (cdr set)))))
</pre></td></tr></table>But that does way more consing than you need.  Instead, you could
replace the <CODE>append</CODE> with <CODE>nconc</CODE>, since you don't have any
need for all the intermediate results.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define x '(a b c))
(define y '(d e f))
(nconc x y)
   => (a b c d e f)
x
   => (a b c d e f)
</pre></td></tr></table><P>

<CODE>nconc</CODE> is the same as <CODE>append!</CODE> in `<TT>sc2.scm</TT>'.
</P>
</DL>
<P>

<A NAME="IDX1317"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>nreverse</B> <I>lst</I>
<DD><CODE>nreverse</CODE> reverses the order of elements in <VAR>lst</VAR> by mutating
<CODE>cdr</CODE>s of the list.  Sometimes called <CODE>reverse!</CODE>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define foo '(a b c))
(nreverse foo)
   => (c b a)
foo
   => (a)
</pre></td></tr></table><P>

Some people have been confused about how to use <CODE>nreverse</CODE>,
thinking that it doesn't return a value.  It needs to be pointed out
that
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! lst (nreverse lst))
</pre></td></tr></table>is the proper usage, not
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(nreverse lst)
</pre></td></tr></table>The example should suffice to show why this is the case.
</DL>
<P>

<A NAME="IDX1318"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>delete</B> <I>elt lst</I>
<DD><A NAME="IDX1319"></A>
<DT><U>Procedure:</U> <B>delete-if</B> <I>pred lst</I>
<DD><A NAME="IDX1320"></A>
<DT><U>Procedure:</U> <B>delete-if-not</B> <I>pred lst</I>
<DD>Destructive versions of <CODE>remove</CODE> <CODE>remove-if</CODE>, and
<CODE>remove-if-not</CODE>.
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define lst (list 'foo 'bar 'baz 'bang))
(delete 'foo lst)
   => (bar baz bang)
lst
   => (foo bar baz bang)

(define lst (list 1 2 3 4 5 6 7 8 9))
(delete-if odd? lst)
   => (2 4 6 8)
lst
   => (1 2 4 6 8)
</pre></td></tr></table><P>

Some people have been confused about how to use <CODE>delete</CODE>,
<CODE>delete-if</CODE>, and <CODE>delete-if</CODE>, thinking that they don't return
a value.  It needs to be pointed out that
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! lst (delete el lst))
</pre></td></tr></table>is the proper usage, not
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(delete el lst)
</pre></td></tr></table>The examples should suffice to show why this is the case.
</DL>
<P>

<A NAME="Non-List functions"></A>
<HR SIZE="6">
<A NAME="SEC213"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC212"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC214"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC208"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.2.1.5 Non-List functions </H4>
<!--docid::SEC213::-->
<P>

<A NAME="IDX1321"></A>
</P>
<DL>
<DT><U>Function:</U> <B>and?</B> <I>arg1 <small>...</small></I>
<DD><CODE>and?</CODE> checks to see if all its arguments are true.  If they are,
<CODE>and?</CODE> returns <CODE>#t</CODE>, otherwise, <CODE>#f</CODE>.  (In contrast to
<CODE>and</CODE>, this is a function, so all arguments are always evaluated
and in an unspecified order.)
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(and? 1 2 3)
   => #t
(and #f 1 2)
   => #f
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1322"></A>
</P>
<DL>
<DT><U>Function:</U> <B>or?</B> <I>arg1 <small>...</small></I>
<DD><CODE>or?</CODE> checks to see if any of its arguments are true.  If any is
true, <CODE>or?</CODE> returns <CODE>#t</CODE>, and <CODE>#f</CODE> otherwise.  (To
<CODE>or</CODE> as <CODE>and?</CODE> is to <CODE>and</CODE>.)
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(or? 1 2 #f)
   => #t
(or? #f #f #f)
   => #f
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1323"></A>
</P>
<DL>
<DT><U>Function:</U> <B>atom?</B> <I>object</I>
<DD>Returns <CODE>#t</CODE> if <VAR>object</VAR> is not a pair and <CODE>#f</CODE> if it is
pair.  (Called <CODE>atom</CODE> in Common LISP.)
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(atom? 1)
   => #t
(atom? '(1 2))
   => #f
(atom? #(1 2))   ; dubious!
   => #t
</pre></td></tr></table></DL>
<P>

<A NAME="Tree Operations"></A>
<HR SIZE="6">
<A NAME="SEC214"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC213"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC215"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.2 Tree operations </H3>
<!--docid::SEC214::-->
<P>

<CODE>(require 'tree)</CODE>
<A NAME="IDX1324"></A>
</P>
<P>

These are operations that treat lists a representations of trees.
</P>
<P>

<A NAME="IDX1325"></A>
</P>
<DL>
<DT><U>Function:</U> <B>subst</B> <I>new old tree</I>
<DD><A NAME="IDX1326"></A>
<DT><U>Function:</U> <B>substq</B> <I>new old tree</I>
<DD><A NAME="IDX1327"></A>
<DT><U>Function:</U> <B>substv</B> <I>new old tree</I>
<DD><P>

<A NAME="IDX1328"></A>
<DT><U>Function:</U> <B>subst</B> <I>new old tree equ?</I>
<DD><CODE>subst</CODE> makes a copy of <VAR>tree</VAR>, substituting <VAR>new</VAR> for
every subtree or leaf of <VAR>tree</VAR> which is <CODE>equal?</CODE> to <VAR>old</VAR>
and returns a modified tree.  The original <VAR>tree</VAR> is unchanged, but
may share parts with the result.
</P>
<P>

<CODE>substq</CODE> and <CODE>substv</CODE> are similar, but test against <VAR>old</VAR>
using <CODE>eq?</CODE> and <CODE>eqv?</CODE> respectively.  If <CODE>subst</CODE> is
called with a fourth argument, <VAR>equ?</VAR> is the equality predicate.
</P>
<P>

Examples:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(substq 'tempest 'hurricane '(shakespeare wrote (the hurricane)))
   => (shakespeare wrote (the tempest))
(substq 'foo '() '(shakespeare wrote (twelfth night)))
   => (shakespeare wrote (twelfth night . foo) . foo)
(subst '(a . cons) '(old . pair)
       '((old . spice) ((old . shoes) old . pair) (old . pair)))
   => ((old . spice) ((old . shoes) a . cons) (a . cons))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1329"></A>
</P>
<DL>
<DT><U>Function:</U> <B>copy-tree</B> <I>tree</I>
<DD><P>

Makes a copy of the nested list structure <VAR>tree</VAR> using new pairs and
returns it.  All levels are copied, so that none of the pairs in the
tree are <CODE>eq?</CODE> to the original ones -- only the leaves are.
</P>
<P>

Example:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define bar '(bar))
(copy-tree (list bar 'foo))
   => ((bar) foo)
(eq? bar (car (copy-tree (list bar 'foo))))
   => #f
</pre></td></tr></table></DL>
<P>

<A NAME="Chapter Ordering"></A>
<HR SIZE="6">
<A NAME="SEC215"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC214"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC216"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.3 Chapter Ordering </H3>
<!--docid::SEC215::-->
<P>

<CODE>(require 'chapter-order)</CODE>
<A NAME="IDX1330"></A>
</P>
<P>

The `<SAMP>chap:</SAMP>' functions deal with strings which are ordered like
chapter numbers (or letters) in a book.  Each section of the string
consists of consecutive numeric or consecutive aphabetic characters of
like case.
</P>
<P>

<A NAME="IDX1331"></A>
</P>
<DL>
<DT><U>Function:</U> <B>chap:string&lt;?</B> <I>string1 string2</I>
<DD><P>

Returns #t if the first non-matching run of alphabetic upper-case or
the first non-matching run of alphabetic lower-case or the first
non-matching run of numeric characters of <VAR>string1</VAR> is
<CODE>string&lt;?</CODE> than the corresponding non-matching run of
characters of <VAR>string2</VAR>.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(chap:string&lt;? &quot;a.9&quot; &quot;a.10&quot;)                    => #t
(chap:string&lt;? &quot;4c&quot; &quot;4aa&quot;)                      => #t
(chap:string&lt;? &quot;Revised^{3.99}&quot; &quot;Revised^{4}&quot;)  => #t
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1332"></A>
</P>
<DL>
<DT><U>Function:</U> <B>chap:string&gt;?</B> <I>string1 string2</I>
<DD><A NAME="IDX1333"></A>
<DT><U>Function:</U> <B>chap:string&lt;=?</B> <I>string1 string2</I>
<DD><A NAME="IDX1334"></A>
<DT><U>Function:</U> <B>chap:string&gt;=?</B> <I>string1 string2</I>
<DD><P>

Implement the corresponding chapter-order predicates.
</P>
</DL>
<P>

<A NAME="IDX1335"></A>
</P>
<DL>
<DT><U>Function:</U> <B>chap:next-string</B> <I>string</I>
<DD><P>

Returns the next string in the <EM>chapter order</EM>.  If <VAR>string</VAR>
has no alphabetic or numeric characters,
<CODE>(string-append <VAR>string</VAR> &quot;0&quot;)</CODE> is returnd.  The argument to
chap:next-string will always be <CODE>chap:string&lt;?</CODE> than the result.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(chap:next-string &quot;a.9&quot;)                => &quot;a.10&quot;
(chap:next-string &quot;4c&quot;)                 => &quot;4d&quot;
(chap:next-string &quot;4z&quot;)                 => &quot;4aa&quot;
(chap:next-string &quot;Revised^{4}&quot;)        => &quot;Revised^{5}&quot;

</pre></td></tr></table></DL>
<P>

<A NAME="Sorting"></A>
<HR SIZE="6">
<A NAME="SEC216"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC215"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC217"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.4 Sorting </H3>
<!--docid::SEC216::-->
<P>

<CODE>(require 'sort)</CODE>
<A NAME="IDX1336"></A>
</P>
<P>

Many Scheme systems provide some kind of sorting functions.  They do
not, however, always provide the <EM>same</EM> sorting functions, and
those that I have had the opportunity to test provided inefficient ones
(a common blunder is to use quicksort which does not perform well).
</P>
<P>

Because <CODE>sort</CODE> and <CODE>sort!</CODE> are not in the standard, there is
very little agreement about what these functions look like.  For
example, Dybvig says that Chez Scheme provides
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(merge predicate list1 list2)
(merge! predicate list1 list2)
(sort predicate list)
(sort! predicate list)
</pre></td></tr></table>while MIT Scheme 7.1, following Common LISP, offers unstable
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(sort list predicate)
</pre></td></tr></table>TI PC Scheme offers
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(sort! list/vector predicate?)
</pre></td></tr></table>and Elk offers
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(sort list/vector predicate?)
(sort! list/vector predicate?)
</pre></td></tr></table><P>

Here is a comprehensive catalogue of the variations I have found.
</P>
<P>

<OL>
<LI>
Both <CODE>sort</CODE> and <CODE>sort!</CODE> may be provided.
<LI>
<CODE>sort</CODE> may be provided without <CODE>sort!</CODE>.
<LI>
<CODE>sort!</CODE> may be provided without <CODE>sort</CODE>.
<LI>
Neither may be provided.
<LI>
The sequence argument may be either a list or a vector.
<LI>
The sequence argument may only be a list.
<LI>
The sequence argument may only be a vector.
<LI>
The comparison function may be expected to behave like <CODE>&lt;</CODE>.
<LI>
The comparison function may be expected to behave like <CODE>&lt;=</CODE>.
<LI>
The interface may be <CODE>(sort predicate? sequence)</CODE>.
<LI>
The interface may be <CODE>(sort sequence predicate?)</CODE>.
<LI>
The interface may be <CODE>(sort sequence &amp;optional (predicate? &lt;))</CODE>.
<LI>
The sort may be stable.
<LI>
The sort may be unstable.
</OL>
<P>

All of this variation really does not help anybody.  A nice simple merge
sort is both stable and fast (quite a lot faster than <EM>quick</EM> sort).
</P>
<P>

I am providing this source code with no restrictions at all on its use
(but please retain D.H.D.Warren's credit for the original idea).  You
may have to rename some of these functions in order to use them in a
system which already provides incompatible or inferior sorts.  For each
of the functions, only the top-level define needs to be edited to do
that.
</P>
<P>

I could have given these functions names which would not clash with any
Scheme that I know of, but I would like to encourage implementors to
converge on a single interface, and this may serve as a hint.  The
argument order for all functions has been chosen to be as close to
Common LISP as made sense, in order to avoid NIH-itis.
</P>
<P>

Each of the five functions has a required <EM>last</EM> parameter which is
a comparison function.  A comparison function <CODE>f</CODE> is a function of
2 arguments which acts like <CODE>&lt;</CODE>.  For example,
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(not (f x x))
(and (f x y) (f y z)) == (f x z)
</pre></td></tr></table><P>

The standard functions <CODE>&lt;</CODE>, <CODE>&gt;</CODE>, <CODE>char&lt;?</CODE>, <CODE>char&gt;?</CODE>,
<CODE>char-ci&lt;?</CODE>, <CODE>char-ci&gt;?</CODE>, <CODE>string&lt;?</CODE>, <CODE>string&gt;?</CODE>,
<CODE>string-ci&lt;?</CODE>, and <CODE>string-ci&gt;?</CODE> are suitable for use as
comparison functions.  Think of <CODE>(less? x y)</CODE> as saying when
<CODE>x</CODE> must <EM>not</EM> precede <CODE>y</CODE>.
</P>
<P>

<A NAME="IDX1337"></A>
</P>
<DL>
<DT><U>Function:</U> <B>sorted?</B> <I>sequence less?</I>
<DD>Returns <CODE>#t</CODE> when the sequence argument is in non-decreasing order
according to <VAR>less?</VAR> (that is, there is no adjacent pair <CODE><small>...</small> x
y <small>...</small></CODE> for which <CODE>(less? y x)</CODE>).
<P>

Returns <CODE>#f</CODE> when the sequence contains at least one out-of-order
pair.  It is an error if the sequence is not a list, vector, or
string.
</P>
</DL>
<P>

<A NAME="IDX1338"></A>
</P>
<DL>
<DT><U>Function:</U> <B>merge</B> <I>list1 list2 less?</I>
<DD>This merges two lists, producing a completely new list as result.  I
gave serious consideration to producing a Common-LISP-compatible
version.  However, Common LISP's <CODE>sort</CODE> is our <CODE>sort!</CODE> (well,
in fact Common LISP's <CODE>stable-sort</CODE> is our <CODE>sort!</CODE>, merge sort
is <EM>fast</EM> as well as stable!) so adapting CL code to Scheme takes a
bit of work anyway.  I did, however, appeal to CL to determine the
<EM>order</EM> of the arguments.
</DL>
<P>

<A NAME="IDX1339"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>merge!</B> <I>list1 list2 less?</I>
<DD>Merges two lists, re-using the pairs of <VAR>list1</VAR> and <VAR>list2</VAR> to
build the result.  If the code is compiled, and <VAR>less?</VAR> constructs
no new pairs, no pairs at all will be allocated.  The first pair of the
result will be either the first pair of <VAR>list1</VAR> or the first pair of
<VAR>list2</VAR>, but you can't predict which.
<P>

The code of <CODE>merge</CODE> and <CODE>merge!</CODE> could have been quite a bit
simpler, but they have been coded to reduce the amount of work done per
iteration.  (For example, we only have one <CODE>null?</CODE> test per
iteration.)
</P>
<P>

</P>
</DL>
<P>

<A NAME="IDX1340"></A>
</P>
<DL>
<DT><U>Function:</U> <B>sort</B> <I>sequence less?</I>
<DD>Accepts either a list, vector, or string; and returns a new sequence
which is sorted.  The new sequence is the same type as the input.
Always <CODE>(sorted? (sort sequence less?) less?)</CODE>.  The original
sequence is not altered in any way.  The new sequence shares its
<EM>elements</EM> with the old one; no elements are copied.
</DL>
<P>

<A NAME="IDX1341"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>sort!</B> <I>sequence less?</I>
<DD>Returns its sorted result in the original boxes.  If the original
sequence is a list, no new storage is allocated at all.  If the
original sequence is a vector or string, the sorted elements are put
back in the same vector or string.
<P>

Some people have been confused about how to use <CODE>sort!</CODE>, thinking
that it doesn't return a value.  It needs to be pointed out that
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! slist (sort! slist &lt;))
</pre></td></tr></table>is the proper usage, not
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(sort! slist &lt;)
</pre></td></tr></table></DL>
<P>

Note that these functions do <EM>not</EM> accept a CL-style `<SAMP>:key</SAMP>'
argument.  A simple device for obtaining the same expressiveness is to
define
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define (keyed less? key)
  (lambda (x y) (less? (key x) (key y))))
</pre></td></tr></table>and then, when you would have written
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(sort a-sequence #'my-less :key #'my-key)
</pre></td></tr></table>in Common LISP, just write
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(sort! a-sequence (keyed my-less? my-key))
</pre></td></tr></table>in Scheme.
<P>

<A NAME="Topological Sort"></A>
<HR SIZE="6">
<A NAME="SEC217"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC216"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC218"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.5 Topological Sort </H3>
<!--docid::SEC217::-->
<P>

<CODE>(require 'topological-sort)</CODE> or <CODE>(require 'tsort)</CODE>
<A NAME="IDX1342"></A>
<A NAME="IDX1343"></A>
</P>
<P>

The algorithm is inspired by Cormen, Leiserson and Rivest (1990)
<CITE>Introduction to Algorithms</CITE>, chapter 23.
</P>
<P>

<A NAME="IDX1344"></A>
</P>
<DL>
<DT><U>Function:</U> <B>tsort</B> <I>dag pred</I>
<DD><P>

<A NAME="IDX1345"></A>
<DT><U>Function:</U> <B>topological-sort</B> <I>dag pred</I>
<DD>where
</P>
<DL COMPACT>
<DT><VAR>dag</VAR>
<DD>is a list of sublists.  The car of each sublist is a vertex.  The cdr is
the adjacency list of that vertex, i.e. a list of all vertices to which
there exists an edge from the car vertex.
<DT><VAR>pred</VAR>
<DD>is one of <CODE>eq?</CODE>, <CODE>eqv?</CODE>, <CODE>equal?</CODE>, <CODE>=</CODE>,
<CODE>char=?</CODE>, <CODE>char-ci=?</CODE>, <CODE>string=?</CODE>, or <CODE>string-ci=?</CODE>.
</DL>
<P>

Sort the directed acyclic graph <VAR>dag</VAR> so that for every edge from
vertex <VAR>u</VAR> to <VAR>v</VAR>, <VAR>u</VAR> will come before <VAR>v</VAR> in the
resulting list of vertices.
</P>
<P>

Time complexity: O (|V| + |E|)
</P>
<P>

Example (from Cormen):
<BLOCKQUOTE>
Prof. Bumstead topologically sorts his clothing when getting
dressed.  The first argument to <CODE>tsort</CODE> describes which
garments he needs to put on before others.  (For example,
Prof Bumstead needs to put on his shirt before he puts on his
tie or his belt.)  <CODE>tsort</CODE> gives the correct order of dressing:
</BLOCKQUOTE>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'tsort)
<A NAME="IDX1346"></A>(tsort '((shirt tie belt)
         (tie jacket)
         (belt jacket)
         (watch)
         (pants shoes belt)
         (undershorts pants shoes)
         (socks shoes))
       eq?)
=>
(socks undershorts pants shoes watch shirt belt tie jacket)
</pre></td></tr></table></DL>
<P>

<A NAME="Hashing"></A>
<HR SIZE="6">
<A NAME="SEC218"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC217"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC219"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.6 Hashing </H3>
<!--docid::SEC218::-->
<P>

<CODE>(require 'hash)</CODE>
<A NAME="IDX1347"></A>
</P>
<P>

These hashing functions are for use in quickly classifying objects.
Hash tables use these functions.
</P>
<P>

<A NAME="IDX1348"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hashq</B> <I>obj k</I>
<DD><A NAME="IDX1349"></A>
<DT><U>Function:</U> <B>hashv</B> <I>obj k</I>
<DD><A NAME="IDX1350"></A>
<DT><U>Function:</U> <B>hash</B> <I>obj k</I>
<DD>Returns an exact non-negative integer less than <VAR>k</VAR>.  For each
non-negative integer less than <VAR>k</VAR> there are arguments <VAR>obj</VAR> for
which the hashing functions applied to <VAR>obj</VAR> and <VAR>k</VAR> returns
that integer.
<P>

For <CODE>hashq</CODE>, <CODE>(eq? obj1 obj2)</CODE> implies <CODE>(= (hashq obj1 k)
(hashq obj2))</CODE>.
</P>
<P>

For <CODE>hashv</CODE>, <CODE>(eqv? obj1 obj2)</CODE> implies <CODE>(= (hashv obj1 k)
(hashv obj2))</CODE>.
</P>
<P>

For <CODE>hash</CODE>, <CODE>(equal? obj1 obj2)</CODE> implies <CODE>(= (hash obj1 k)
(hash obj2))</CODE>.
</P>
<P>

<CODE>hash</CODE>, <CODE>hashv</CODE>, and <CODE>hashq</CODE> return in time bounded by a
constant.  Notice that items having the same <CODE>hash</CODE> implies the
items have the same <CODE>hashv</CODE> implies the items have the same
<CODE>hashq</CODE>.
</P>
</DL>
<P>

<A NAME="Space-Filling Curves"></A>
<HR SIZE="6">
<A NAME="SEC219"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC218"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC220"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.7 Space-Filling Curves </H3>
<!--docid::SEC219::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC220">7.2.7.1 Peano-Hilbert Space-Filling Curve</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC221">7.2.7.2 Sierpinski Curve</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<P>

<A NAME="Peano-Hilbert Space-Filling Curve"></A>
<HR SIZE="6">
<A NAME="SEC220"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC219"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC221"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC219"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.2.7.1 Peano-Hilbert Space-Filling Curve </H4>
<!--docid::SEC220::-->
<P>

<CODE>(require 'hilbert-fill)</CODE>
<A NAME="IDX1351"></A>
</P>
<P>

<A NAME="IDX1352"></A>
<A NAME="IDX1353"></A>
<A NAME="IDX1354"></A>
The <EM>Peano-Hilbert Space-Filling Curve</EM> is a one-to-one mapping
<A NAME="IDX1355"></A>
between a unit line segment and an <VAR>n</VAR>-dimensional unit cube.
</P>
<P>

The integer procedures map the non-negative integers to an
arbitrarily large <VAR>n</VAR>-dimensional cube with its corner at the
origin and all coordinates are non-negative.
</P>
<P>

For any exact nonnegative integers <VAR>scalar</VAR> and <VAR>rank</VAR>,
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(= <VAR>scalar</VAR> (hilbert-coordinates-&gt;integer
           (integer-&gt;hilbert-coordinates <VAR>scalar</VAR> <VAR>rank</VAR>)))
                                       => #t
</pre></td></tr></table><P>

<A NAME="IDX1356"></A>
</P>
<DL>
<DT><U>Function:</U> <B>integer-&gt;hilbert-coordinates</B> <I>scalar rank</I>
<DD><P>

Returns a list of <VAR>rank</VAR> integer coordinates corresponding to exact
non-negative integer <VAR>scalar</VAR>.  The lists returned by <CODE>integer-&gt;hilbert-coordinates</CODE> for <VAR>scalar</VAR> arguments
0 and 1 will differ in the first element.
</P>
</DL>
<P>

<A NAME="IDX1357"></A>
</P>
<DL>
<DT><U>Function:</U> <B>hilbert-coordinates-&gt;integer</B> <I>coords</I>
<DD><P>

Returns an exact non-negative integer corresponding to <VAR>coords</VAR>, a list
of non-negative integer coordinates.
</P>
</DL>
<P>

<A NAME="Sierpinski Curve"></A>
<HR SIZE="6">
<A NAME="SEC221"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC220"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC222"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC219"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.2.7.2 Sierpinski Curve </H4>
<!--docid::SEC221::-->
<P>

<CODE>(require 'sierpinski)</CODE>
<A NAME="IDX1358"></A>
</P>
<P>

<A NAME="IDX1359"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-sierpinski-indexer</B> <I>max-coordinate</I>
<DD>Returns a procedure (eg hash-function) of 2 numeric arguments which
preserves <EM>nearness</EM> in its mapping from NxN to N.
<P>

<VAR>max-coordinate</VAR> is the maximum coordinate (a positive integer) of a
population of points.  The returned procedures is a function that takes
the x and y coordinates of a point, (non-negative integers) and returns
an integer corresponding to the relative position of that point along a
Sierpinski curve.  (You can think of this as computing a (pseudo-)
inverse of the Sierpinski spacefilling curve.)
</P>
<P>

Example use: Make an indexer (hash-function) for integer points lying in
square of integer grid points [0,99]x[0,99]:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define space-key (make-sierpinski-indexer 100))
</pre></td></tr></table>Now let's compute the index of some points:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(space-key 24 78)               => 9206
(space-key 23 80)               => 9172
</pre></td></tr></table><P>

Note that locations (24, 78) and (23, 80) are near in index and
therefore, because the Sierpinski spacefilling curve is continuous, we
know they must also be near in the plane.  Nearness in the plane does
not, however, necessarily correspond to nearness in index, although it
<EM>tends</EM> to be so.
</P>
<P>

Example applications:
<UL>

<LI>
Sort points by Sierpinski index to get heuristic solution to
<EM>travelling salesman problem</EM>.  For details of performance,
see L. Platzman and J. Bartholdi, &quot;Spacefilling curves and the
Euclidean travelling salesman problem&quot;, JACM 36(4):719--737
(October 1989) and references therein.
<P>

</P>
<LI>
Use Sierpinski index as key by which to store 2-dimensional data
in a 1-dimensional data structure (such as a table).  Then
locations that are near each other in 2-d space will tend to
be near each other in 1-d data structure; and locations that
are near in 1-d data structure will be near in 2-d space.  This
can significantly speed retrieval from secondary storage because
contiguous regions in the plane will tend to correspond to
contiguous regions in secondary storage.  (This is a standard
technique for managing CAD/CAM or geographic data.)
<P>

</UL>
</DL>
<P>

<A NAME="Soundex"></A>
<HR SIZE="6">
<A NAME="SEC222"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC221"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC223"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.8 Soundex </H3>
<!--docid::SEC222::-->
<P>

<CODE>(require 'soundex)</CODE>
<A NAME="IDX1360"></A>
</P>
<P>

<A NAME="IDX1361"></A>
</P>
<DL>
<DT><U>Function:</U> <B>soundex</B> <I>name</I>
<DD>Computes the <EM>soundex</EM> hash of <VAR>name</VAR>.  Returns a string of an
initial letter and up to three digits between 0 and 6.  Soundex
supposedly has the property that names that sound similar in normal
English pronunciation tend to map to the same key.
<P>

Soundex was a classic algorithm used for manual filing of personal
records before the advent of computers.  It performs adequately for
English names but has trouble with other languages.
</P>
<P>

See Knuth, Vol. 3 <CITE>Sorting and searching</CITE>, pp 391--2
</P>
<P>

To manage unusual inputs, <CODE>soundex</CODE> omits all non-alphabetic
characters.  Consequently, in this implementation:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(soundex &lt;string of blanks&gt;)    => &quot;&quot;
(soundex &quot;&quot;)                    => &quot;&quot;
</pre></td></tr></table><P>

Examples from Knuth:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(map soundex '(&quot;Euler&quot; &quot;Gauss&quot; &quot;Hilbert&quot; &quot;Knuth&quot;
                       &quot;Lloyd&quot; &quot;Lukasiewicz&quot;))
        => (&quot;E460&quot; &quot;G200&quot; &quot;H416&quot; &quot;K530&quot; &quot;L300&quot; &quot;L222&quot;)

(map soundex '(&quot;Ellery&quot; &quot;Ghosh&quot; &quot;Heilbronn&quot; &quot;Kant&quot;
                        &quot;Ladd&quot; &quot;Lissajous&quot;))
        => (&quot;E460&quot; &quot;G200&quot; &quot;H416&quot; &quot;K530&quot; &quot;L300&quot; &quot;L222&quot;)
</pre></td></tr></table><P>

Some cases in which the algorithm fails (Knuth):
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(map soundex '(&quot;Rogers&quot; &quot;Rodgers&quot;))     => (&quot;R262&quot; &quot;R326&quot;)

(map soundex '(&quot;Sinclair&quot; &quot;St. Clair&quot;)) => (&quot;S524&quot; &quot;S324&quot;)

(map soundex '(&quot;Tchebysheff&quot; &quot;Chebyshev&quot;)) => (&quot;T212&quot; &quot;C121&quot;)
</pre></td></tr></table></DL>
<P>

<A NAME="String Search"></A>
<HR SIZE="6">
<A NAME="SEC223"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC222"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC224"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.9 String Search </H3>
<!--docid::SEC223::-->
<P>

<CODE>(require 'string-search)</CODE>
<A NAME="IDX1362"></A>
</P>
<P>

<A NAME="IDX1363"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>string-index</B> <I>string char</I>
<DD><A NAME="IDX1364"></A>
<DT><U>Procedure:</U> <B>string-index-ci</B> <I>string char</I>
<DD>Returns the index of the first occurence of <VAR>char</VAR> within
<VAR>string</VAR>, or <CODE>#f</CODE> if the <VAR>string</VAR> does not contain a
character <VAR>char</VAR>.
</DL>
<P>

<A NAME="IDX1365"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>string-reverse-index</B> <I>string char</I>
<DD><A NAME="IDX1366"></A>
<DT><U>Procedure:</U> <B>string-reverse-index-ci</B> <I>string char</I>
<DD>Returns the index of the last occurence of <VAR>char</VAR> within
<VAR>string</VAR>, or <CODE>#f</CODE> if the <VAR>string</VAR> does not contain a
character <VAR>char</VAR>.
</DL>
<P>

<A NAME="IDX1367"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>substring?</B> <I>pattern string</I>
<DD><A NAME="IDX1368"></A>
<DT><U>Procedure:</U> <B>substring-ci?</B> <I>pattern string</I>
<DD>Searches <VAR>string</VAR> to see if some substring of <VAR>string</VAR> is equal
to <VAR>pattern</VAR>.  <CODE>substring?</CODE> returns the index of the first
character of the first substring of <VAR>string</VAR> that is equal to
<VAR>pattern</VAR>; or <CODE>#f</CODE> if <VAR>string</VAR> does not contain
<VAR>pattern</VAR>.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(substring? &quot;rat&quot; &quot;pirate&quot;) =>  2
(substring? &quot;rat&quot; &quot;outrage&quot;) =>  #f
(substring? &quot;&quot; any-string) =>  0
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1369"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>find-string-from-port?</B> <I>str in-port max-no-chars</I>
<DD>Looks for a string <VAR>str</VAR> within the first <VAR>max-no-chars</VAR> chars
of the input port <VAR>in-port</VAR>.
<P>

<A NAME="IDX1370"></A>
<DT><U>Procedure:</U> <B>find-string-from-port?</B> <I>str in-port</I>
<DD>When called with two arguments, the search span is limited by the end of
the input stream.
</P>
<P>

<A NAME="IDX1371"></A>
<DT><U>Procedure:</U> <B>find-string-from-port?</B> <I>str in-port char</I>
<DD>Searches up to the first occurrence of character <VAR>char</VAR> in
<VAR>str</VAR>.
</P>
<P>

<A NAME="IDX1372"></A>
<DT><U>Procedure:</U> <B>find-string-from-port?</B> <I>str in-port proc</I>
<DD>Searches up to the first occurrence of the procedure <VAR>proc</VAR>
returning non-false when called with a character (from <VAR>in-port</VAR>)
argument.
</P>
<P>

When the <VAR>str</VAR> is found, <CODE>find-string-from-port?</CODE> returns the
number of characters it has read from the port, and the port is set to
read the first char after that (that is, after the <VAR>str</VAR>) The
function returns <CODE>#f</CODE> when the <VAR>str</VAR> isn't found.
</P>
<P>

<CODE>find-string-from-port?</CODE> reads the port <EM>strictly</EM>
sequentially, and does not perform any buffering.  So
<CODE>find-string-from-port?</CODE> can be used even if the <VAR>in-port</VAR> is
open to a pipe or other communication channel.
</P>
</DL>
<P>

<A NAME="IDX1373"></A>
</P>
<DL>
<DT><U>Function:</U> <B>string-subst</B> <I>txt old1 new1 <small>...</small></I>
<DD>Returns a copy of string <VAR>txt</VAR> with all occurrences of string
<VAR>old1</VAR> in <VAR>txt</VAR> replaced with <VAR>new1</VAR>; then <VAR>old2</VAR>
replaced with <VAR>new2</VAR> <small>...</small>.  Matches are found from the left.
Matches do not overlap.
</DL>
<P>

<A NAME="IDX1374"></A>
</P>
<DL>
<DT><U>Function:</U> <B>count-newlines</B> <I>str</I>
<DD>Returns the number of `<SAMP>#\newline</SAMP>' characters in string <VAR>str</VAR>.
</DL>
<P>

<A NAME="Sequence Comparison"></A>
<HR SIZE="6">
<A NAME="SEC224"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC223"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC207"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.2.10 Sequence Comparison </H3>
<!--docid::SEC224::-->
<P>

<CODE>(require 'diff)</CODE>
<A NAME="IDX1375"></A>
<A NAME="IDX1376"></A>
</P>
<P>

<CODE>diff:edit-length</CODE> implements the algorithm:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>S. Wu, E. Myers, U. Manber, and W. Miller,
   &quot;An O(NP) Sequence Comparison Algorithm,&quot;
   Information Processing Letters 35, 6 (1990), 317-323.
   <A HREF="http://www.cs.arizona.edu/people/gene/vita.html">http://www.cs.arizona.edu/people/gene/vita.html</A>
</pre></td></tr></table>S. Wu, &lt;A HREF=&quot;http://www.cs.arizona.edu/people/gene/vita.html&quot;&gt;
E. Myers,&lt;/A&gt; U. Manber, and W. Miller,
&lt;A HREF=&quot;http://www.cs.arizona.edu/people/gene/PAPERS/np_diff.ps&quot;&gt;
&quot;An O(NP) Sequence Comparison Algorithm,&quot;&lt;/A&gt;
Information Processing Letters 35, 6 (1990), 317-323.
<P>

The values returned by <CODE>diff:edit-length</CODE> can be used to gauge
the degree of match between two sequences.
</P>
<P>

Surprisingly, &quot;An O(NP) Sequence Comparison Algorithm&quot; does not
derive the edit sequence; only the sequence length.  Developing this
linear-space sub-quadratic-time algorithm for computing the edit
sequence required hundreds of hours of work.  I have submitted a
paper describing the algorithm to the Journal of Computational
Biology.
</P>
<P>

If the items being sequenced are text lines, then the computed
edit-list is equivalent to the output of the <EM>diff</EM> utility
<A NAME="IDX1377"></A>
program.  If the items being sequenced are words, then it is like the
lesser known <EM>spiff</EM> program.
<A NAME="IDX1378"></A>
</P>
<P>

<A NAME="IDX1379"></A>
</P>
<DL>
<DT><U>Function:</U> <B>diff:longest-common-subsequence</B> <I>array1 array2 =? p-lim</I>
<DD><P>

<A NAME="IDX1380"></A>
<DT><U>Function:</U> <B>diff:longest-common-subsequence</B> <I>array1 array2 =?</I>
<DD><VAR>array1</VAR> and <VAR>array2</VAR> are one-dimensional arrays.  The procedure <VAR>=?</VAR> is used
to compare sequence tokens for equality.
</P>
<P>

The non-negative integer <VAR>p-lim</VAR>, if provided, is maximum number of
deletions of the shorter sequence to allow.  <CODE>diff:longest-common-subsequence</CODE> will return <CODE>#f</CODE>
if more deletions would be necessary.
</P>
<P>

<CODE>diff:longest-common-subsequence</CODE> returns a one-dimensional array of length <CODE>(quotient (- (+
len1 len2) (diff:edit-length <VAR>array1</VAR> <VAR>array2</VAR>)) 2)</CODE> holding the longest sequence
common to both <VAR>array</VAR>s.
</P>
</DL>
<P>

<A NAME="IDX1381"></A>
</P>
<DL>
<DT><U>Function:</U> <B>diff:edits</B> <I>array1 array2 =? p-lim</I>
<DD><P>

<A NAME="IDX1382"></A>
<DT><U>Function:</U> <B>diff:edits</B> <I>array1 array2 =?</I>
<DD><VAR>array1</VAR> and <VAR>array2</VAR> are one-dimensional arrays.  The procedure <VAR>=?</VAR> is used
to compare sequence tokens for equality.
</P>
<P>

The non-negative integer <VAR>p-lim</VAR>, if provided, is maximum number of
deletions of the shorter sequence to allow.  <CODE>diff:edits</CODE> will return <CODE>#f</CODE>
if more deletions would be necessary.
</P>
<P>

<CODE>diff:edits</CODE> returns a vector of length <CODE>(diff:edit-length <VAR>array1</VAR> <VAR>array2</VAR>)</CODE> composed
of a shortest sequence of edits transformaing <VAR>array1</VAR> to <VAR>array2</VAR>.
</P>
<P>

Each edit is an integer:
</P>
<DL COMPACT>
<DT><VAR>k</VAR> &gt; 0
<DD>Inserts <CODE>(array-ref <VAR>array1</VAR> (+ -1 <VAR>j</VAR>))</CODE> into the sequence.
<DT><VAR>k</VAR> &lt; 0
<DD>Deletes <CODE>(array-ref <VAR>array2</VAR> (- -1 <VAR>k</VAR>))</CODE> from the sequence.
</DL>
</DL>
<P>

<A NAME="IDX1383"></A>
</P>
<DL>
<DT><U>Function:</U> <B>diff:edit-length</B> <I>array1 array2 =? p-lim</I>
<DD><P>

<A NAME="IDX1384"></A>
<DT><U>Function:</U> <B>diff:edit-length</B> <I>array1 array2 =?</I>
<DD><VAR>array1</VAR> and <VAR>array2</VAR> are one-dimensional arrays.  The procedure <VAR>=?</VAR> is used
to compare sequence tokens for equality.
</P>
<P>

The non-negative integer <VAR>p-lim</VAR>, if provided, is maximum number of
deletions of the shorter sequence to allow.  <CODE>diff:edit-length</CODE> will return <CODE>#f</CODE>
if more deletions would be necessary.
</P>
<P>

<CODE>diff:edit-length</CODE> returns the length of the shortest sequence of edits transformaing
<VAR>array1</VAR> to <VAR>array2</VAR>.
</P>
</DL>
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(diff:longest-common-subsequence &quot;fghiejcklm&quot; &quot;fgehijkpqrlm&quot; eqv?)
=> &quot;fghijklm&quot;

(diff:edit-length &quot;fghiejcklm&quot; &quot;fgehijkpqrlm&quot; eqv?)
=> 6

(diff:edits &quot;fghiejcklm&quot; &quot;fgehijkpqrlm&quot; eqv?)
=> #As32(3 -5 -7 8 9 10)
       ; e  c  h p q  r
</pre></td></tr></table><P>

<A NAME="Procedures"></A>
<HR SIZE="6">
<A NAME="SEC225"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC224"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC226"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 7.3 Procedures </H2>
<!--docid::SEC225::-->
<P>

Anything that doesn't fall neatly into any of the other categories winds
up here.
</P>
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC226">7.3.1 Type Coercion</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'coerce</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC227">7.3.2 String-Case</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'string-case</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC228">7.3.3 String Ports</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'string-port</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC229">7.3.4 Line I/O</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'line-i/o</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC230">7.3.5 Multi-Processing</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'process</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC231">7.3.6 Metric Units</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Portable manifest types for numeric values.</TD></TR>
</TABLE>
<P>

<A NAME="Type Coercion"></A>
<HR SIZE="6">
<A NAME="SEC226"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC227"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.3.1 Type Coercion </H3>
<!--docid::SEC226::-->
<CODE>(require 'coerce)</CODE>
<A NAME="IDX1385"></A>
<P>

<A NAME="IDX1386"></A>
</P>
<DL>
<DT><U>Function:</U> <B>type-of</B> <I>obj</I>
<DD><P>

Returns a symbol name for the type of <VAR>obj</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1387"></A>
</P>
<DL>
<DT><U>Function:</U> <B>coerce</B> <I>obj result-type</I>
<DD><P>

Converts and returns <VAR>obj</VAR> of type <CODE>char</CODE>, <CODE>number</CODE>,
<CODE>string</CODE>, <CODE>symbol</CODE>, <CODE>list</CODE>, or <CODE>vector</CODE> to
<VAR>result-type</VAR> (which must be one of these symbols).
</P>
</DL>
<P>

<A NAME="String-Case"></A>
<HR SIZE="6">
<A NAME="SEC227"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC226"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC228"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.3.2 String-Case </H3>
<!--docid::SEC227::-->
<P>

<CODE>(require 'string-case)</CODE>
<A NAME="IDX1388"></A>
</P>
<P>

<A NAME="IDX1389"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>string-upcase</B> <I>str</I>
<DD><A NAME="IDX1390"></A>
<DT><U>Procedure:</U> <B>string-downcase</B> <I>str</I>
<DD><A NAME="IDX1391"></A>
<DT><U>Procedure:</U> <B>string-capitalize</B> <I>str</I>
<DD>The obvious string conversion routines.  These are non-destructive.
</DL>
<P>

<A NAME="IDX1392"></A>
</P>
<DL>
<DT><U>Function:</U> <B>string-upcase!</B> <I>str</I>
<DD><A NAME="IDX1393"></A>
<DT><U>Function:</U> <B>string-downcase!</B> <I>str</I>
<DD><A NAME="IDX1394"></A>
<DT><U>Function:</U> <B>string-capitalize!</B> <I>str</I>
<DD>The destructive versions of the functions above.
</DL>
<P>

<A NAME="IDX1395"></A>
</P>
<DL>
<DT><U>Function:</U> <B>string-ci-&gt;symbol</B> <I>str</I>
<DD>Converts string <VAR>str</VAR> to a symbol having the same case as if the
symbol had been <CODE>read</CODE>.
</DL>
<P>

<A NAME="IDX1396"></A>
</P>
<DL>
<DT><U>Function:</U> <B>symbol-append</B> <I>obj1 <small>...</small></I>
<DD>Converts <VAR>obj1</VAR> <small>...</small> to strings, appends them, and converts to a
symbol which is returned.  Strings and numbers are converted to read's
symbol case; the case of symbol characters is not changed.  #f is
converted to the empty string (symbol).
</DL>
<P>

<A NAME="IDX1397"></A>
</P>
<DL>
<DT><U>Function:</U> <B>StudlyCapsExpand</B> <I>str delimiter</I>
<DD><A NAME="IDX1398"></A>
<DT><U>Function:</U> <B>StudlyCapsExpand</B> <I>str</I>
<DD><VAR>delimiter</VAR> must be a string or character.  If absent,
<VAR>delimiter</VAR> defaults to `<SAMP>-</SAMP>'.  <CODE>StudlyCapsExpand</CODE> returns a
copy of <VAR>str</VAR> where <VAR>delimiter</VAR> is inserted between each
lower-case character immediately followed by an upper-case character;
and between two upper-case characters immediately followed by a
lower-case character.
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(StudlyCapsExpand &quot;aX&quot; &quot; &quot;)   => &quot;a X&quot;
(StudlyCapsExpand &quot;aX&quot; &quot;..&quot;)  => &quot;a..X&quot;
(StudlyCapsExpand &quot;AX&quot;)       => &quot;AX&quot;
(StudlyCapsExpand &quot;Ax&quot;)       => &quot;Ax&quot;
(StudlyCapsExpand &quot;AXLE&quot;)     => &quot;AXLE&quot;
(StudlyCapsExpand &quot;aAXACz&quot;)   => &quot;a-AXA-Cz&quot;
(StudlyCapsExpand &quot;AaXACz&quot;)   => &quot;Aa-XA-Cz&quot;
(StudlyCapsExpand &quot;AAaXACz&quot;)  => &quot;A-Aa-XA-Cz&quot;
(StudlyCapsExpand &quot;AAaXAC&quot;)   => &quot;A-Aa-XAC&quot;
</pre></td></tr></table><P>

</P>
</DL>
<P>

<A NAME="String Ports"></A>
<HR SIZE="6">
<A NAME="SEC228"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC227"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC229"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.3.3 String Ports </H3>
<!--docid::SEC228::-->
<P>

<CODE>(require 'string-port)</CODE>
<A NAME="IDX1399"></A>
</P>
<P>

<A NAME="IDX1400"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>call-with-output-string</B> <I>proc</I>
<DD><VAR>proc</VAR> must be a procedure of one argument.  This procedure calls
<VAR>proc</VAR> with one argument: a (newly created) output port.  When the
function returns, the string composed of the characters written into the
port is returned.
</DL>
<P>

<A NAME="IDX1401"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>call-with-input-string</B> <I>string proc</I>
<DD><VAR>proc</VAR> must be a procedure of one argument.  This procedure calls
<VAR>proc</VAR> with one argument: an (newly created) input port from which
<VAR>string</VAR>'s contents may be read.  When <VAR>proc</VAR> returns, the port
is closed and the value yielded by the procedure <VAR>proc</VAR> is
returned.
</DL>
<P>

<A NAME="Line I/O"></A>
<HR SIZE="6">
<A NAME="SEC229"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC228"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC230"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.3.4 Line I/O </H3>
<!--docid::SEC229::-->
<P>

<CODE>(require 'line-i/o)</CODE>
<A NAME="IDX1402"></A>
</P>
<P>

<A NAME="IDX1403"></A>
</P>
<DL>
<DT><U>Function:</U> <B>read-line</B>
<DD><P>

<A NAME="IDX1404"></A>
<DT><U>Function:</U> <B>read-line</B> <I>port</I>
<DD>Returns a string of the characters up to, but not including a
newline or end of file, updating <VAR>port</VAR> to point to the
character following the newline.  If no characters are available, an
end of file object is returned.  The <VAR>port</VAR> argument may be
omitted, in which case it defaults to the value returned by
<CODE>current-input-port</CODE>.
</P>
</DL>
<P>

<A NAME="IDX1405"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>read-line!</B> <I>string</I>
<DD><P>

<A NAME="IDX1406"></A>
<DT><U>Procedure:</U> <B>read-line!</B> <I>string port</I>
<DD>Fills <VAR>string</VAR> with characters up to, but not including a newline or end
of file, updating the <VAR>port</VAR> to point to the last character read
or following the newline if it was read.  If no characters are
available, an end of file object is returned.  If a newline or end
of file was found, the number of characters read is returned.
Otherwise, <CODE>#f</CODE> is returned.  The <VAR>port</VAR> argument may be
omitted, in which case it defaults to the value returned by
<CODE>current-input-port</CODE>.
</P>
</DL>
<P>

<A NAME="IDX1407"></A>
</P>
<DL>
<DT><U>Function:</U> <B>write-line</B> <I>string</I>
<DD><P>

<A NAME="IDX1408"></A>
<DT><U>Function:</U> <B>write-line</B> <I>string port</I>
<DD>Writes <VAR>string</VAR> followed by a newline to the given <VAR>port</VAR> and returns
an unspecified value.  The <VAR>Port</VAR> argument may be omitted, in
which case it defaults to the value returned by
<CODE>current-input-port</CODE>.
</P>
</DL>
<P>

<A NAME="IDX1409"></A>
</P>
<DL>
<DT><U>Function:</U> <B>system-&gt;line</B> <I>command tmp</I>
<DD><P>

<A NAME="IDX1410"></A>
<DT><U>Function:</U> <B>system-&gt;line</B> <I>command</I>
<DD><VAR>command</VAR> must be a string.  The string <VAR>tmp</VAR>, if supplied, is a path to use as
a temporary file.  <CODE>system-&gt;line</CODE> calls <CODE>system</CODE> with <VAR>command</VAR> as argument,
redirecting stdout to file <VAR>tmp</VAR>.  <CODE>system-&gt;line</CODE> returns a string containing the
first line of output from <VAR>tmp</VAR>.
</P>
</DL>
<P>

<A NAME="Multi-Processing"></A>
<HR SIZE="6">
<A NAME="SEC230"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC229"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC231"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.3.5 Multi-Processing </H3>
<!--docid::SEC230::-->
<P>

<CODE>(require 'process)</CODE>
<A NAME="IDX1411"></A>
</P>
<P>

This module implements asynchronous (non-polled) time-sliced
multi-processing in the SCM Scheme implementation using procedures
<CODE>alarm</CODE> and <CODE>alarm-interrupt</CODE>.
<A NAME="IDX1412"></A>
<A NAME="IDX1413"></A>
Until this is ported to another implementation, consider it an example
of writing schedulers in Scheme.
</P>
<P>

<A NAME="IDX1414"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>add-process!</B> <I>proc</I>
<DD>Adds proc, which must be a procedure (or continuation) capable of
accepting accepting one argument, to the <CODE>process:queue</CODE>.  The
value returned is unspecified.  The argument to <VAR>proc</VAR> should be
ignored.  If <VAR>proc</VAR> returns, the process is killed.
</DL>
<P>

<A NAME="IDX1415"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>process:schedule!</B>
<DD>Saves the current process on <CODE>process:queue</CODE> and runs the next
process from <CODE>process:queue</CODE>.  The value returned is
unspecified.
</DL>
<P>

<A NAME="IDX1416"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>kill-process!</B>
<DD>Kills the current process and runs the next process from
<CODE>process:queue</CODE>.  If there are no more processes on
<CODE>process:queue</CODE>, <CODE>(slib:exit)</CODE> is called (see section <A HREF="slib_2.html#SEC17">2.4 System</A>).
</DL>
<P>

<A NAME="Metric Units"></A>
<HR SIZE="6">
<A NAME="SEC231"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC230"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC232"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.3.6 Metric Units </H3>
<!--docid::SEC231::-->
<P>

<CODE>(require 'metric-units)</CODE>
<A NAME="IDX1417"></A>
</P>
<P>

<A HREF="http://swissnet.ai.mit.edu/~jaffer/MIXF.html">http://swissnet.ai.mit.edu/~jaffer/MIXF.html</A>
</P>
<P>

<EM>Metric Interchange Format</EM> is a character string encoding for
numerical values and units which:
</P>
<P>

<UL>
<LI>
is unambiguous in all locales;
<P>

</P>
<LI>
uses only [TOG] &quot;Portable Character Set&quot; characters matching &quot;Basic
Latin&quot; characters in Plane 0 of the Universal Character Set [UCS];
<P>

</P>
<LI>
is transparent to [UTF-7] and [UTF-8] UCS transformation formats;
<P>

</P>
<LI>
is human readable and writable;
<P>

</P>
<LI>
is machine readable and writable;
<P>

</P>
<LI>
incorporates SI prefixes and units;
<P>

</P>
<LI>
incorporates [ISO 6093] numbers; and
<P>

</P>
<LI>
incorporates [IEC 60027-2] binary prefixes.
</UL>
<P>

In the expression for the value of a quantity, the unit symbol is placed
after the numerical value.  A dot (PERIOD, `<SAMP>.</SAMP>') is placed between
the numerical value and the unit symbol.
</P>
<P>

Within a compound unit, each of the base and derived symbols can
optionally have an attached SI prefix.
</P>
<P>

Unit symbols formed from other unit symbols by multiplication are
indicated by means of a dot (PERIOD, `<SAMP>.</SAMP>') placed between them.
</P>
<P>

Unit symbols formed from other unit symbols by division are indicated by
means of a SOLIDUS (`<SAMP>/</SAMP>') or negative exponents.  The SOLIDUS must
not be repeated in the same compound unit unless contained within a
parenthesized subexpression.
</P>
<P>

The grouping formed by a prefix symbol attached to a unit symbol
constitutes a new inseparable symbol (forming a multiple or submultiple
of the unit concerned) which can be raised to a positive or negative
power and which can be combined with other unit symbols to form compound
unit symbols.
</P>
<P>

The grouping formed by surrounding compound unit symbols with
parentheses (`<SAMP>(</SAMP>' and `<SAMP>)</SAMP>') constitutes a new inseparable symbol
which can be raised to a positive or negative power and which can be
combined with other unit symbols to form compound unit symbols.
</P>
<P>

Compound prefix symbols, that is, prefix symbols formed by the
juxtaposition of two or more prefix symbols, are not permitted.
</P>
<P>

Prefix symbols are not used with the time-related unit symbols min
(minute), h (hour), d (day).  No prefix symbol may be used with dB
(decibel).  Only submultiple prefix symbols may be used with the unit
symbols L (liter), Np (neper), o (degree), oC (degree Celsius), rad
(radian), and sr (steradian).  Submultiple prefix symbols may not be
used with the unit symbols t (metric ton), r (revolution), or Bd (baud).
</P>
<P>

A unit exponent follows the unit, separated by a CIRCUMFLEX (`<SAMP>^</SAMP>').
Exponents may be positive or negative.  Fractional exponents must be
parenthesized.
</P>
<P>

<HR SIZE="6">
<A NAME="SEC232"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC231"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC233"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.3.6.1 SI Prefixes </H4>
<!--docid::SEC232::-->
<TABLE><tr><td>&nbsp;</td><td class=example><pre>       Factor     Name    Symbol  |  Factor     Name    Symbol
       ======     ====    ======  |  ======     ====    ======
        1e24      yotta      Y    |   1e-1      deci       d
        1e21      zetta      Z    |   1e-2      centi      c
        1e18      exa        E    |   1e-3      milli      m
        1e15      peta       P    |   1e-6      micro      u
        1e12      tera       T    |   1e-9      nano       n
        1e9       giga       G    |   1e-12     pico       p
        1e6       mega       M    |   1e-15     femto      f
        1e3       kilo       k    |   1e-18     atto       a
        1e2       hecto      h    |   1e-21     zepto      z
        1e1       deka       da   |   1e-24     yocto      y
</pre></td></tr></table><P>

<HR SIZE="6">
<A NAME="SEC233"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC232"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC234"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.3.6.2 Binary Prefixes </H4>
<!--docid::SEC233::-->
<P>

These binary prefixes are valid only with the units B (byte) and bit.
However, decimal prefixes can also be used with bit; and decimal
multiple (not submultiple) prefixes can also be used with B (byte).
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>                Factor       (power-of-2)  Name  Symbol
                ======       ============  ====  ======
       1.152921504606846976e18  (2^60)     exbi    Ei
          1.125899906842624e15  (2^50)     pebi    Pi
             1.099511627776e12  (2^40)     tebi    Ti
                1.073741824e9   (2^30)     gibi    Gi
                   1.048576e6   (2^20)     mebi    Mi
                      1.024e3   (2^10)     kibi    Ki
</pre></td></tr></table><P>

<HR SIZE="6">
<A NAME="SEC234"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC233"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.3.6.3 Unit Symbols </H4>
<!--docid::SEC234::-->
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>    Type of Quantity      Name          Symbol   Equivalent
    ================      ====          ======   ==========
time                      second           s
time                      minute           min = 60.s
time                      hour             h   = 60.min
time                      day              d   = 24.h
frequency                 hertz            Hz    s^-1
signaling rate            baud             Bd    s^-1
length                    meter            m
volume                    liter            L     dm^3
plane angle               radian           rad
solid angle               steradian        sr    rad^2
plane angle               revolution     * r   = 6.283185307179586.rad
plane angle               degree         * o   = 2.777777777777778e-3.r
information capacity      bit              bit
information capacity      byte, octet      B   = 8.bit
mass                      gram             g
mass                      ton              t     Mg
mass              unified atomic mass unit u   = 1.66053873e-27.kg
amount of substance       mole             mol
catalytic activity        katal            kat   mol/s
thermodynamic temperature kelvin           K
centigrade temperature    degree Celsius   oC
luminous intensity        candela          cd
luminous flux             lumen            lm    cd.sr
illuminance               lux              lx    lm/m^2
force                     newton           N     m.kg.s^-2
pressure, stress          pascal           Pa    N/m^2
energy, work, heat        joule            J     N.m
energy                    electronvolt     eV  = 1.602176462e-19.J
power, radiant flux       watt             W     J/s
logarithm of power ratio  neper            Np
logarithm of power ratio  decibel        * dB  = 0.1151293.Np
electric current          ampere           A
electric charge           coulomb          C     s.A
electric potential, EMF   volt             V     W/A
capacitance               farad            F     C/V
electric resistance       ohm              Ohm   V/A
electric conductance      siemens          S     A/V
magnetic flux             weber            Wb    V.s
magnetic flux density     tesla            T     Wb/m^2
inductance                henry            H     Wb/A
radionuclide activity     becquerel        Bq    s^-1
absorbed dose energy      gray             Gy    m^2.s^-2
dose equivalent           sievert          Sv    m^2.s^-2
</pre></td></tr></table><P>

* The formulas are:
</P>
<P>

<UL>
<LI>
r/rad = 8 * atan(1)
<LI>
o/r = 1 / 360
<LI>
db/Np = ln(10) / 20
</UL>
<P>

<A NAME="IDX1418"></A>
</P>
<DL>
<DT><U>Function:</U> <B>si:conversion-factor</B> <I>to-unit from-unit</I>
<DD>If the strings <VAR>from-unit</VAR> and <VAR>to-unit</VAR> express valid unit
expressions for quantities of the same unit-dimensions, then the value
returned by <CODE>si:conversion-factor</CODE> will be such that multiplying a
numerical value expressed in <VAR>from-unit</VAR>s by the returned conversion
factor yields the numerical value expressed in <VAR>to-unit</VAR>s.
<P>

Otherwise, <CODE>si:conversion-factor</CODE> returns:
</P>
<P>

</P>
<DL COMPACT>
<DT>-3
<DD>if neither <VAR>from-unit</VAR> nor <VAR>to-unit</VAR> is a syntactically valid
unit.
<DT>-2
<DD>if <VAR>from-unit</VAR> is not a syntactically valid unit.
<DT>-1
<DD>if <VAR>to-unit</VAR> is not a syntactically valid unit.
<DT>0
<DD>if linear conversion (by a factor) is not possible.
</DL>
<P>

</P>
</DL>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(si:conversion-factor &quot;km/s&quot; &quot;m/s&quot; ) => 0.001     
(si:conversion-factor &quot;N&quot;    &quot;m/s&quot; ) => 0         
(si:conversion-factor &quot;moC&quot;  &quot;oC&quot;  ) => 1000      
(si:conversion-factor &quot;mK&quot;   &quot;oC&quot;  ) => 0         
(si:conversion-factor &quot;rad&quot;  &quot;o&quot;   ) => 0.0174533 
(si:conversion-factor &quot;K&quot;    &quot;o&quot;   ) => 0         
(si:conversion-factor &quot;K&quot;    &quot;K&quot;   ) => 1         
(si:conversion-factor &quot;oK&quot;   &quot;oK&quot;  ) => -3        
(si:conversion-factor &quot;&quot;     &quot;s/s&quot; ) => 1         
(si:conversion-factor &quot;km/h&quot; &quot;mph&quot; ) => -2        
</pre></td></tr></table><P>

<A NAME="Standards Support"></A>
<HR SIZE="6">
<A NAME="SEC235"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC234"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC236"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 7.4 Standards Support </H2>
<!--docid::SEC235::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC236">7.4.1 RnRS</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Revised Reports on Scheme</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC237">7.4.2 With-File</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'with-file</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC238">7.4.3 Transcripts</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'transcript</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC239">7.4.4 Rev2 Procedures</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'rev2-procedures</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC240">7.4.5 Rev4 Optional Procedures</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'rev4-optional-procedures</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC241">7.4.6 Multi-argument / and -</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'multiarg/and-</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC242">7.4.7 Multi-argument Apply</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'multiarg-apply</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC243">7.4.8 Rationalize</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'rationalize</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC244">7.4.9 Promises</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'delay</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC245">7.4.10 Dynamic-Wind</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'dynamic-wind</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC246">7.4.11 Eval</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'eval</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC247">7.4.12 Values</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'values</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC248">7.4.13 SRFI</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'http://srfi.schemers.org/srfi-0/srfi-0.html</TD></TR>
</TABLE>
<P>

<A NAME="RnRS"></A>
<HR SIZE="6">
<A NAME="SEC236"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC237"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.1 RnRS </H3>
<!--docid::SEC236::-->
<P>

The <CODE>r2rs</CODE>, <CODE>r3rs</CODE>, <CODE>r4rs</CODE>, and <CODE>r5rs</CODE> features
attempt to provide procedures and macros to bring a Scheme
implementation to the desired version of Scheme.
</P>
<P>

<A NAME="IDX1419"></A>
</P>
<DL>
<DT><U>Feature:</U> <B>r2rs</B>
<DD><A NAME="IDX1420"></A>
Requires features implementing procedures and optional procedures
specified by <CITE>Revised^2 Report on the Algorithmic Language Scheme</CITE>;
namely <CODE>rev3-procedures</CODE> and <CODE>rev2-procedures</CODE>.
</DL>
<P>

<A NAME="IDX1421"></A>
</P>
<DL>
<DT><U>Feature:</U> <B>r3rs</B>
<DD><A NAME="IDX1422"></A>
Requires features implementing procedures and optional procedures
specified by <CITE>Revised^3 Report on the Algorithmic Language Scheme</CITE>;
namely <CODE>rev3-procedures</CODE>.
<P>

<EM>Note:</EM> SLIB already mandates the <CODE>r3rs</CODE> procedures which can
be portably implemented in <CODE>r4rs</CODE> implementations.
</P>
</DL>
<P>

<A NAME="IDX1423"></A>
</P>
<DL>
<DT><U>Feature:</U> <B>r4rs</B>
<DD><A NAME="IDX1424"></A>
Requires features implementing procedures and optional procedures
specified by <CITE>Revised^4 Report on the Algorithmic Language Scheme</CITE>;
namely <CODE>rev4-optional-procedures</CODE>.
</DL>
<P>

<A NAME="IDX1425"></A>
</P>
<DL>
<DT><U>Feature:</U> <B>r5rs</B>
<DD><A NAME="IDX1426"></A>
Requires features implementing procedures and optional procedures
specified by <CITE>Revised^5 Report on the Algorithmic Language Scheme</CITE>;
namely <CODE>values</CODE>, <CODE>macro</CODE>, and <CODE>eval</CODE>.
</DL>
<P>

<A NAME="With-File"></A>
<HR SIZE="6">
<A NAME="SEC237"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC236"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC238"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.2 With-File </H3>
<!--docid::SEC237::-->
<P>

<CODE>(require 'with-file)</CODE>
<A NAME="IDX1427"></A>
</P>
<P>

<A NAME="IDX1428"></A>
</P>
<DL>
<DT><U>Function:</U> <B>with-input-from-file</B> <I>file thunk</I>
<DD><A NAME="IDX1429"></A>
<DT><U>Function:</U> <B>with-output-to-file</B> <I>file thunk</I>
<DD>Description found in R4RS.
</DL>
<P>

<A NAME="Transcripts"></A>
<HR SIZE="6">
<A NAME="SEC238"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC237"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC239"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.3 Transcripts </H3>
<!--docid::SEC238::-->
<P>

<CODE>(require 'transcript)</CODE>
<A NAME="IDX1430"></A>
</P>
<P>

<A NAME="IDX1431"></A>
</P>
<DL>
<DT><U>Function:</U> <B>transcript-on</B> <I>filename</I>
<DD><A NAME="IDX1432"></A>
<DT><U>Function:</U> <B>transcript-off</B> <I>filename</I>
<DD>Redefines <CODE>read-char</CODE>, <CODE>read</CODE>, <CODE>write-char</CODE>,
<CODE>write</CODE>, <CODE>display</CODE>, and <CODE>newline</CODE>.
</DL>
<P>

<A NAME="Rev2 Procedures"></A>
<HR SIZE="6">
<A NAME="SEC239"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC238"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC240"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.4 Rev2 Procedures </H3>
<!--docid::SEC239::-->
<P>

<CODE>(require 'rev2-procedures)</CODE>
<A NAME="IDX1433"></A>
</P>
<P>

The procedures below were specified in the <CITE>Revised^2 Report on
Scheme</CITE>.  <STRONG>N.B.</STRONG>: The symbols <CODE>1+</CODE> and <CODE>-1+</CODE> are not
<CITE>R4RS</CITE> syntax.  Scheme-&gt;C, for instance, chokes on this
module.
</P>
<P>

<A NAME="IDX1434"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>substring-move-left!</B> <I>string1 start1 end1 string2 start2</I>
<DD><A NAME="IDX1435"></A>
<DT><U>Procedure:</U> <B>substring-move-right!</B> <I>string1 start1 end1 string2 start2</I>
<DD><VAR>string1</VAR> and <VAR>string2</VAR> must be a strings, and <VAR>start1</VAR>,
<VAR>start2</VAR> and <VAR>end1</VAR> must be exact integers satisfying
<P>

<TABLE><tr><td>&nbsp;</td><td class=display><pre style="font-family: serif">0 &lt;= <VAR>start1</VAR> &lt;= <VAR>end1</VAR> &lt;= (string-length <VAR>string1</VAR>)
0 &lt;= <VAR>start2</VAR> &lt;= <VAR>end1</VAR> - <VAR>start1</VAR> + <VAR>start2</VAR> &lt;= (string-length <VAR>string2</VAR>)
</pre></td></tr></table><P>

<CODE>substring-move-left!</CODE> and <CODE>substring-move-right!</CODE> store
characters of <VAR>string1</VAR> beginning with index <VAR>start1</VAR>
(inclusive) and ending with index <VAR>end1</VAR> (exclusive) into
<VAR>string2</VAR> beginning with index <VAR>start2</VAR> (inclusive).
</P>
<P>

<CODE>substring-move-left!</CODE> stores characters in time order of
increasing indices.  <CODE>substring-move-right!</CODE> stores characters in
time order of increasing indeces.
</P>
</DL>
<P>

<A NAME="IDX1436"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>substring-fill!</B> <I>string start end char</I>
<DD>Fills the elements <VAR>start</VAR>--<VAR>end</VAR> of <VAR>string</VAR> with the
character <VAR>char</VAR>.
</DL>
<P>

<A NAME="IDX1437"></A>
</P>
<DL>
<DT><U>Function:</U> <B>string-null?</B> <I>str</I>
<DD>== <CODE>(= 0 (string-length <VAR>str</VAR>))</CODE>
</DL>
<P>

<A NAME="IDX1438"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>append!</B> <I>pair1 <small>...</small></I>
<DD>Destructively appends its arguments.  Equivalent to <CODE>nconc</CODE>.
</DL>
<P>

<A NAME="IDX1439"></A>
</P>
<DL>
<DT><U>Function:</U> <B>1+</B> <I>n</I>
<DD>Adds 1 to <VAR>n</VAR>.
</DL>
<P>

<A NAME="IDX1440"></A>
</P>
<DL>
<DT><U>Function:</U> <B>-1+</B> <I>n</I>
<DD>Subtracts 1 from <VAR>n</VAR>.
</DL>
<P>

<A NAME="IDX1441"></A>
</P>
<DL>
<DT><U>Function:</U> <B>&lt;?</B>
<DD><A NAME="IDX1442"></A>
<DT><U>Function:</U> <B>&lt;=?</B>
<DD><A NAME="IDX1443"></A>
<DT><U>Function:</U> <B>=?</B>
<DD><A NAME="IDX1444"></A>
<DT><U>Function:</U> <B>&gt;?</B>
<DD><A NAME="IDX1445"></A>
<DT><U>Function:</U> <B>&gt;=?</B>
<DD>These are equivalent to the procedures of the same name but without the
trailing `<SAMP>?</SAMP>'.
</DL>
<P>

<A NAME="Rev4 Optional Procedures"></A>
<HR SIZE="6">
<A NAME="SEC240"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC239"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC241"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.5 Rev4 Optional Procedures </H3>
<!--docid::SEC240::-->
<P>

<CODE>(require 'rev4-optional-procedures)</CODE>
<A NAME="IDX1446"></A>
</P>
<P>

For the specification of these optional procedures,
See section `Standard procedures' in <CITE>Revised(4) Scheme</CITE>.
</P>
<P>

<A NAME="IDX1447"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-tail</B> <I>l p</I>
<DD></DL>
<P>

<A NAME="IDX1448"></A>
</P>
<DL>
<DT><U>Function:</U> <B>string-&gt;list</B> <I>s</I>
<DD></DL>
<P>

<A NAME="IDX1449"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-&gt;string</B> <I>l</I>
<DD></DL>
<P>

<A NAME="IDX1450"></A>
</P>
<DL>
<DT><U>Function:</U> <B>string-copy</B>
<DD></DL>
<P>

<A NAME="IDX1451"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>string-fill!</B> <I>s obj</I>
<DD></DL>
<P>

<A NAME="IDX1452"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-&gt;vector</B> <I>l</I>
<DD></DL>
<P>

<A NAME="IDX1453"></A>
</P>
<DL>
<DT><U>Function:</U> <B>vector-&gt;list</B> <I>s</I>
<DD></DL>
<P>

<A NAME="IDX1454"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>vector-fill!</B> <I>s obj</I>
<DD></DL>
<P>

<A NAME="Multi-argument / and -"></A>
<HR SIZE="6">
<A NAME="SEC241"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC240"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC242"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.6 Multi-argument / and - </H3>
<!--docid::SEC241::-->
<P>

<CODE>(require 'multiarg/and-)</CODE>
<A NAME="IDX1455"></A>
</P>
<P>

For the specification of these optional forms, See section `Numerical operations' in <CITE>Revised(4) Scheme</CITE>.
</P>
<P>

<A NAME="IDX1456"></A>
</P>
<DL>
<DT><U>Function:</U> <B>/</B> <I>dividend divisor1 <small>...</small></I>
<DD></DL>
<P>

<A NAME="IDX1457"></A>
</P>
<DL>
<DT><U>Function:</U> <B>-</B> <I>minuend subtrahend1 <small>...</small></I>
<DD></DL>
<P>

<A NAME="Multi-argument Apply"></A>
<HR SIZE="6">
<A NAME="SEC242"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC241"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC243"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.7 Multi-argument Apply </H3>
<!--docid::SEC242::-->
<P>

<CODE>(require 'multiarg-apply)</CODE>
<A NAME="IDX1458"></A>
</P>
<P>

For the specification of this optional form,
See section `Control features' in <CITE>Revised(4) Scheme</CITE>.
</P>
<P>

<A NAME="IDX1459"></A>
</P>
<DL>
<DT><U>Function:</U> <B>apply</B> <I>proc arg1 <small>...</small></I>
<DD></DL>
<P>

<A NAME="Rationalize"></A>
<HR SIZE="6">
<A NAME="SEC243"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC242"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC244"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.8 Rationalize </H3>
<!--docid::SEC243::-->
<P>

<CODE>(require 'rationalize)</CODE>
<A NAME="IDX1460"></A>
</P>
<P>

<A NAME="IDX1461"></A>
</P>
<DL>
<DT><U>Function:</U> <B>rationalize</B> <I>x e</I>
<DD><P>

Computes the correct result for exact arguments (provided the
implementation supports exact rational numbers of unlimited precision);
and produces a reasonable answer for inexact arguments when inexact
arithmetic is implemented using floating-point.
</P>
<P>

</P>
</DL>
<CODE>Rationalize</CODE> has limited use in implementations lacking exact
(non-integer) rational numbers.  The following procedures return a list
of the numerator and denominator.
<P>

<A NAME="IDX1462"></A>
</P>
<DL>
<DT><U>Function:</U> <B>find-ratio</B> <I>x e</I>
<DD><P>

<CODE>find-ratio</CODE> returns the list of the <EM>simplest</EM>
numerator and denominator whose quotient differs from <VAR>x</VAR> by no more
than <VAR>e</VAR>.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=display><pre style="font-family: serif"><TT>(find-ratio 3/97 .0001)             => (3 97)
(find-ratio 3/97 .001)              => (1 32)
</TT>
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1463"></A>
</P>
<DL>
<DT><U>Function:</U> <B>find-ratio-between</B> <I>x y</I>
<DD><P>

<CODE>find-ratio-between</CODE> returns the list of the <EM>simplest</EM>
numerator and denominator between <VAR>x</VAR> and <VAR>y</VAR>.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=display><pre style="font-family: serif"><TT>(find-ratio-between 2/7 3/5)        => (1 2)
(find-ratio-between -3/5 -2/7)      => (-1 2)
</TT>
</pre></td></tr></table></DL>
<P>

<A NAME="Promises"></A>
<HR SIZE="6">
<A NAME="SEC244"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC243"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC245"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.9 Promises </H3>
<!--docid::SEC244::-->
<P>

<CODE>(require 'promise)</CODE>
<A NAME="IDX1464"></A>
</P>
<P>

<A NAME="IDX1465"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-promise</B> <I>proc</I>
<DD></DL>
<P>

<A NAME="IDX1466"></A>
</P>
<DL>
<DT><U>Function:</U> <B>force</B> <I>promise</I>
<DD></DL>
<P>

<CODE>(require 'delay)</CODE> provides <CODE>force</CODE> and <CODE>delay</CODE>:
</P>
<P>

<A NAME="IDX1467"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>delay</B> <I>obj</I>
<DD>Change occurrences of <CODE>(delay <VAR>expression</VAR>)</CODE> to
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(make-promise (lambda () <VAR>expression</VAR>))
</pre></td></tr></table><P>

</P>
</DL>
<P>

(see section `Control features' in <CITE>Revised(4) Scheme</CITE>).
</P>
<P>

<A NAME="Dynamic-Wind"></A>
<HR SIZE="6">
<A NAME="SEC245"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC244"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC246"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.10 Dynamic-Wind </H3>
<!--docid::SEC245::-->
<P>

<CODE>(require 'dynamic-wind)</CODE>
<A NAME="IDX1468"></A>
</P>
<P>

This facility is a generalization of Common LISP <CODE>unwind-protect</CODE>,
designed to take into account the fact that continuations produced by
<CODE>call-with-current-continuation</CODE> may be reentered.
</P>
<P>

<A NAME="IDX1469"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>dynamic-wind</B> <I>thunk1 thunk2 thunk3</I>
<DD>The arguments <VAR>thunk1</VAR>, <VAR>thunk2</VAR>, and <VAR>thunk3</VAR> must all be
procedures of no arguments (thunks).
<P>

<CODE>dynamic-wind</CODE> calls <VAR>thunk1</VAR>, <VAR>thunk2</VAR>, and then
<VAR>thunk3</VAR>.  The value returned by <VAR>thunk2</VAR> is returned as the
result of <CODE>dynamic-wind</CODE>.  <VAR>thunk3</VAR> is also called just before
control leaves the dynamic context of <VAR>thunk2</VAR> by calling a
continuation created outside that context.  Furthermore, <VAR>thunk1</VAR> is
called before reentering the dynamic context of <VAR>thunk2</VAR> by calling
a continuation created inside that context.  (Control is inside the
context of <VAR>thunk2</VAR> if <VAR>thunk2</VAR> is on the current return stack).
</P>
<P>

<STRONG>Warning:</STRONG> There is no provision for dealing with errors or
interrupts.  If an error or interrupt occurs while using
<CODE>dynamic-wind</CODE>, the dynamic environment will be that in effect at
the time of the error or interrupt.
</P>
</DL>
<P>

<A NAME="Eval"></A>
<HR SIZE="6">
<A NAME="SEC246"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC245"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC247"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.11 Eval </H3>
<!--docid::SEC246::-->
<P>

<CODE>(require 'eval)</CODE>
<A NAME="IDX1470"></A>
</P>
<P>

<A NAME="IDX1471"></A>
</P>
<DL>
<DT><U>Function:</U> <B>eval</B> <I>expression environment-specifier</I>
<DD><P>

Evaluates <VAR>expression</VAR> in the specified environment and returns its
value.  <VAR>Expression</VAR> must be a valid Scheme expression represented
as data, and <VAR>environment-specifier</VAR> must be a value returned by one
of the three procedures described below.  Implementations may extend
<CODE>eval</CODE> to allow non-expression programs (definitions) as the first
argument and to allow other values as environments, with the restriction
that <CODE>eval</CODE> is not allowed to create new bindings in the
environments associated with <CODE>null-environment</CODE> or
<CODE>scheme-report-environment</CODE>.
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(eval '(* 7 3) (scheme-report-environment 5))
                                                   =>  21

(let ((f (eval '(lambda (f x) (f x x))
               (null-environment))))
  (f + 10))
                                                   =>  20
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1472"></A>
</P>
<DL>
<DT><U>Function:</U> <B>scheme-report-environment</B> <I>version</I>
<DD><A NAME="IDX1473"></A>
<DT><U>Function:</U> <B>null-environment</B> <I>version</I>
<DD><A NAME="IDX1474"></A>
<DT><U>Function:</U> <B>null-environment</B>
<DD><P>

<VAR>Version</VAR> must be an exact non-negative integer <VAR>n</VAR>
corresponding to a version of one of the Revised^<VAR>n</VAR> Reports on
Scheme.  <CODE>Scheme-report-environment</CODE> returns a specifier for an
environment that contains the set of bindings specified in the
corresponding report that the implementation supports.
<CODE>Null-environment</CODE> returns a specifier for an environment that
contains only the (syntactic) bindings for all the syntactic keywords
defined in the given version of the report.
</P>
<P>

Not all versions may be available in all implementations at all times.
However, an implementation that conforms to version <VAR>n</VAR> of the
Revised^<VAR>n</VAR> Reports on Scheme must accept version <VAR>n</VAR>.  An error
is signalled if the specified version is not available.
</P>
<P>

The effect of assigning (through the use of <CODE>eval</CODE>) a variable
bound in a <CODE>scheme-report-environment</CODE> (for example <CODE>car</CODE>) is
unspecified. Thus the environments specified by
<CODE>scheme-report-environment</CODE> may be immutable.
</P>
<P>

</P>
</DL>
<P>

<A NAME="IDX1475"></A>
</P>
<DL>
<DT><U>Function:</U> <B>interaction-environment</B>
<DD><P>

This optional procedure returns a specifier for the environment that
contains implementation-defined bindings, typically a superset of those
listed in the report.  The intent is that this procedure will return the
environment in which the implementation would evaluate expressions
dynamically typed by the user.
</P>
</DL>
<P>

Here are some more <CODE>eval</CODE> examples:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'eval)
=> #&lt;unspecified&gt;
(define car 'volvo)
=> #&lt;unspecified&gt;
car
=> volvo
(eval 'car (interaction-environment))
=> volvo
(eval 'car (scheme-report-environment 5))
=> #&lt;primitive-procedure car&gt;
(eval '(eval 'car (interaction-environment))
      (scheme-report-environment 5))
=> volvo
(eval '(eval '(set! car 'buick) (interaction-environment))
      (scheme-report-environment 5))
=> #&lt;unspecified&gt;
car
=> buick
(eval 'car (scheme-report-environment 5))
=> #&lt;primitive-procedure car&gt;
(eval '(eval 'car (interaction-environment))
      (scheme-report-environment 5))
=> buick
</pre></td></tr></table><P>

<A NAME="Values"></A>
<HR SIZE="6">
<A NAME="SEC247"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC246"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC248"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.12 Values </H3>
<!--docid::SEC247::-->
<P>

<CODE>(require 'values)</CODE>
<A NAME="IDX1476"></A>
</P>
<P>

<A NAME="IDX1477"></A>
</P>
<DL>
<DT><U>Function:</U> <B>values</B> <I>obj <small>...</small></I>
<DD><CODE>values</CODE> takes any number of arguments, and passes (returns) them
to its continuation.
</DL>
<P>

<A NAME="IDX1478"></A>
</P>
<DL>
<DT><U>Function:</U> <B>call-with-values</B> <I>thunk proc</I>
<DD><VAR>thunk</VAR> must be a procedure of no arguments, and <VAR>proc</VAR> must be
a procedure.  <CODE>call-with-values</CODE> calls <VAR>thunk</VAR> with a
continuation that, when passed some values, calls <VAR>proc</VAR> with those
values as arguments.
<P>

Except for continuations created by the <CODE>call-with-values</CODE>
procedure, all continuations take exactly one value, as now; the effect
of passing no value or more than one value to continuations that were
not created by the <CODE>call-with-values</CODE> procedure is
unspecified.
</P>
</DL>
<P>

<A NAME="SRFI"></A>
<HR SIZE="6">
<A NAME="SEC248"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC247"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC249"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC235"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.4.13 SRFI </H3>
<!--docid::SEC248::-->
<P>

<CODE>(require 'srfi)</CODE>
<A NAME="IDX1479"></A>
</P>
<P>

Implements <EM>Scheme Request For Implementation</EM> (SRFI) as
<A NAME="IDX1480"></A>
described at <A HREF="http://srfi.schemers.org/">http://srfi.schemers.org/</A>
</P>
<P>

The Copyright terms of each SRFI states:
<BLOCKQUOTE>
&quot;However, this document itself may not be modified in any way, ...&quot;
</BLOCKQUOTE>
<P>

Therefore, the specification of SRFI constructs must not be
quoted without including the complete SRFI document containing
discussion and a sample implementation program.
</P>
<P>

<A NAME="IDX1481"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>cond-expand</B> <I>&lt;clause1&gt; &lt;clause2&gt; <small>...</small></I>
<DD><P>

<EM>Syntax:</EM>
Each &lt;clause&gt; should be of the form
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=display><pre style="font-family: serif"><TT>(&lt;feature&gt; &lt;expression1&gt; <small>...</small>)</TT>
</pre></td></tr></table><P>

where &lt;feature&gt; is a boolean expression composed of symbols and
`and', `or', and `not' of boolean expressions.  The last &lt;clause&gt;
may be an &quot;else clause,&quot; which has the form
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=display><pre style="font-family: serif"><TT>(else &lt;expression1&gt; &lt;expression2&gt; <small>...</small>).</TT>
</pre></td></tr></table><P>

The first clause whose feature expression is satisfied is expanded.
If no feature expression is satisfied and there is no else clause, an
error is signaled.
</P>
<P>

SLIB <CODE>cond-expand</CODE> is an extension of SRFI-0,
<A HREF="http://srfi.schemers.org/srfi-0/srfi-0.html">http://srfi.schemers.org/srfi-0/srfi-0.html</A>.
</P>
</DL>
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC249">7.4.13.1 SRFI-1</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">list-processing</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC260">7.4.13.2 SRFI-2</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">guarded LET* special form</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC261">7.4.13.3 SRFI-8</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Binding to multiple values</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC262">7.4.13.4 SRFI-9</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Defining Record Types</TD></TR>
</TABLE>
<P>

<A NAME="SRFI-1"></A>
<HR SIZE="6">
<A NAME="SEC249"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC248"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC260"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC248"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.4.13.1 SRFI-1 </H4>
<!--docid::SEC249::-->
<P>

<CODE>(require 'srfi-1)</CODE>
<A NAME="IDX1482"></A>
</P>
<P>

Implements the <EM>SRFI-1</EM> <EM>list-processing library</EM> as described
<A NAME="IDX1483"></A>
<A NAME="IDX1484"></A>
at <A HREF="http://srfi.schemers.org/srfi-1/srfi-1.html">http://srfi.schemers.org/srfi-1/srfi-1.html</A>
</P>
<P>

<A NAME="SEC250"></A>
<H3> Constructors </H3>
<!--docid::SEC250::-->
<P>

<A NAME="IDX1485"></A>
</P>
<DL>
<DT><U>Function:</U> <B>xcons</B> <I>d a</I>
<DD><CODE>(define (xcons d a) (cons a d))</CODE>.
</DL>
<P>

<A NAME="IDX1486"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-tabulate</B> <I>len proc</I>
<DD>Returns a list of length <VAR>len</VAR>.  Element <VAR>i</VAR> is <CODE>(<VAR>proc</VAR>
<VAR>i</VAR>)</CODE> for 0 &lt;= <VAR>i</VAR> &lt; <VAR>len</VAR>.
</DL>
<P>

<A NAME="IDX1487"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cons*</B> <I>obj1 obj2</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1488"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-copy</B> <I>flist</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1489"></A>
</P>
<DL>
<DT><U>Function:</U> <B>iota</B> <I>count start step</I>
<DD><P>

<A NAME="IDX1490"></A>
<DT><U>Function:</U> <B>iota</B> <I>count start</I>
<DD></P>
<P>

<A NAME="IDX1491"></A>
<DT><U>Function:</U> <B>iota</B> <I>count</I>
<DD>Returns a list of <VAR>count</VAR> numbers: (<VAR>start</VAR>, <VAR>start</VAR>+<VAR>step</VAR>, <small>...</small>,  <VAR>start</VAR>+(<VAR>count</VAR>-1)*<VAR>step</VAR>).
</P>
</DL>
<P>

<A NAME="IDX1492"></A>
</P>
<DL>
<DT><U>Function:</U> <B>circular-list</B> <I>obj1 obj2 <small>...</small></I>
<DD><P>

Returns a circular list of <VAR>obj1</VAR>, <VAR>obj2</VAR>, <small>...</small>.
</P>
</DL>
<A NAME="SEC251"></A>
<H3> Predicates </H3>
<!--docid::SEC251::-->
<P>

<A NAME="IDX1493"></A>
</P>
<DL>
<DT><U>Function:</U> <B>proper-list?</B> <I>obj</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1494"></A>
</P>
<DL>
<DT><U>Function:</U> <B>circular-list?</B> <I>x</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1495"></A>
</P>
<DL>
<DT><U>Function:</U> <B>dotted-list?</B> <I>obj</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1496"></A>
</P>
<DL>
<DT><U>Function:</U> <B>null-list?</B> <I>obj</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1497"></A>
</P>
<DL>
<DT><U>Function:</U> <B>not-pair?</B> <I>obj</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1498"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list=</B> <I>=pred list <small>...</small></I>
<DD><P>

</P>
</DL>
<A NAME="SEC252"></A>
<H3> Selectors </H3>
<!--docid::SEC252::-->
<P>

<A NAME="IDX1499"></A>
</P>
<DL>
<DT><U>Function:</U> <B>first</B> <I>pair</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1500"></A>
</P>
<DL>
<DT><U>Function:</U> <B>second</B> <I>pair</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1501"></A>
</P>
<DL>
<DT><U>Function:</U> <B>third</B> <I>pair</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1502"></A>
</P>
<DL>
<DT><U>Function:</U> <B>fourth</B> <I>pair</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1503"></A>
</P>
<DL>
<DT><U>Function:</U> <B>fifth</B> <I>pair</I>
<DD><A NAME="IDX1504"></A>
<DT><U>Function:</U> <B>sixth</B> <I>obj</I>
<DD><A NAME="IDX1505"></A>
<DT><U>Function:</U> <B>seventh</B> <I>obj</I>
<DD><A NAME="IDX1506"></A>
<DT><U>Function:</U> <B>eighth</B> <I>obj</I>
<DD><A NAME="IDX1507"></A>
<DT><U>Function:</U> <B>ninth</B> <I>obj</I>
<DD><A NAME="IDX1508"></A>
<DT><U>Function:</U> <B>tenth</B> <I>obj</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1509"></A>
</P>
<DL>
<DT><U>Function:</U> <B>car+cdr</B> <I>pair</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1510"></A>
</P>
<DL>
<DT><U>Function:</U> <B>drop</B> <I>lst k</I>
<DD><A NAME="IDX1511"></A>
<DT><U>Function:</U> <B>take</B> <I>lst k</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1512"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>take!</B> <I>lst k</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1513"></A>
</P>
<DL>
<DT><U>Function:</U> <B>take-right</B> <I>lst k</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1514"></A>
</P>
<DL>
<DT><U>Function:</U> <B>drop-right</B> <I>lst k</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1515"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>drop-right!</B> <I>lst k</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1516"></A>
</P>
<DL>
<DT><U>Function:</U> <B>split-at</B> <I>lst k</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1517"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>split-at!</B> <I>lst k</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1518"></A>
</P>
<DL>
<DT><U>Function:</U> <B>last</B> <I>lst</I>
<DD><P>

(car (last-pair lst))
</P>
</DL>
<A NAME="SEC253"></A>
<H3> Miscellaneous </H3>
<!--docid::SEC253::-->
<P>

<A NAME="IDX1519"></A>
</P>
<DL>
<DT><U>Function:</U> <B>length+</B> <I>obj</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1520"></A>
</P>
<DL>
<DT><U>Function:</U> <B>concatenate</B> <I>lists</I>
<DD><A NAME="IDX1521"></A>
<DT><U>Function:</U> <B>concatenate!</B> <I>lists</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1522"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>reverse!</B> <I>lst</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1523"></A>
</P>
<DL>
<DT><U>Function:</U> <B>append-reverse</B> <I>rev-head tail</I>
<DD><A NAME="IDX1524"></A>
<DT><U>Function:</U> <B>append-reverse!</B> <I>rev-head tail</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1525"></A>
</P>
<DL>
<DT><U>Function:</U> <B>zip</B> <I>list1 list2 <small>...</small></I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1526"></A>
</P>
<DL>
<DT><U>Function:</U> <B>unzip1</B> <I>lst</I>
<DD><A NAME="IDX1527"></A>
<DT><U>Function:</U> <B>unzip2</B> <I>lst</I>
<DD><A NAME="IDX1528"></A>
<DT><U>Function:</U> <B>unzip3</B> <I>lst</I>
<DD><A NAME="IDX1529"></A>
<DT><U>Function:</U> <B>unzip4</B> <I>lst</I>
<DD><A NAME="IDX1530"></A>
<DT><U>Function:</U> <B>unzip5</B> <I>lst</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1531"></A>
</P>
<DL>
<DT><U>Function:</U> <B>count</B> <I>pred list1 list2 <small>...</small></I>
<DD><P>

</P>
</DL>
<A NAME="SEC254"></A>
<H3> Fold and Unfold </H3>
<!--docid::SEC254::-->
<P>

<A NAME="IDX1532"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>map!</B> <I>f list1 clist2 <small>...</small></I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1533"></A>
</P>
<DL>
<DT><U>Function:</U> <B>pair-for-each</B> <I>f clist1 clist2 <small>...</small></I>
<DD><P>

</P>
</DL>
<A NAME="SEC255"></A>
<H3> Filtering and Partitioning </H3>
<!--docid::SEC255::-->
<P>

<A NAME="IDX1534"></A>
</P>
<DL>
<DT><U>Function:</U> <B>filter</B> <I>pred lis</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1535"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>filter!</B> <I>pred l</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1536"></A>
</P>
<DL>
<DT><U>Function:</U> <B>partition</B> <I>pred list</I>
<DD><P>

</P>
</DL>
<A NAME="SEC256"></A>
<H3> Searching </H3>
<!--docid::SEC256::-->
<P>

<A NAME="IDX1537"></A>
</P>
<DL>
<DT><U>Function:</U> <B>find</B> <I>pred list</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1538"></A>
</P>
<DL>
<DT><U>Function:</U> <B>find-tail</B> <I>pred list</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1539"></A>
</P>
<DL>
<DT><U>Function:</U> <B>remove</B> <I>pred l</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1540"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>remove!</B> <I>pred l</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1541"></A>
</P>
<DL>
<DT><U>Function:</U> <B>any</B> <I>pred clist1 clist2 <small>...</small></I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1542"></A>
</P>
<DL>
<DT><U>Function:</U> <B>list-index</B> <I>pred clist1 clist2 <small>...</small></I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1543"></A>
</P>
<DL>
<DT><U>Function:</U> <B>span</B> <I>pred list</I>
<DD><P>

</P>
</DL>
<P>

<A NAME="IDX1544"></A>
</P>
<DL>
<DT><U>Function:</U> <B>member</B> <I>obj list pred</I>
<DD><P>

<A NAME="IDX1545"></A>
<DT><U>Function:</U> <B>member</B> <I>obj list</I>
<DD></P>
<P>

<CODE>member</CODE> returns the first sublist of <VAR>list</VAR> whose car is <VAR>obj</VAR>, where the sublists
of <VAR>list</VAR> are the non-empty lists returned by <TT>(list-tail <VAR>list</VAR> <VAR>k</VAR>)</TT>
for <VAR>k</VAR> less than the length of <VAR>list</VAR>.  If <VAR>obj</VAR> does not occur in <VAR>list</VAR>,
then <TT>#f</TT> (not the empty list) is returned.  The procedure <VAR>pred</VAR> is
used for testing equality.  If <VAR>pred</VAR> is not provided, `<SAMP>equal?</SAMP>' is
used.
</P>
</DL>
<A NAME="SEC257"></A>
<H3> Deleting </H3>
<!--docid::SEC257::-->
<P>

<A NAME="SEC258"></A>
<H3> Association lists </H3>
<!--docid::SEC258::-->
<P>

<A NAME="IDX1546"></A>
</P>
<DL>
<DT><U>Function:</U> <B>assoc</B> <I>obj alist pred</I>
<DD><P>

<A NAME="IDX1547"></A>
<DT><U>Function:</U> <B>assoc</B> <I>obj alist</I>
<DD></P>
<P>

<VAR>alist</VAR> (for &quot;association list&quot;) must be a list of pairs.  These
procedures find the first pair in <VAR>alist</VAR> whose car field is <VAR>obj</VAR>, and
returns that pair.  If no pair in <VAR>alist</VAR> has <VAR>obj</VAR> as its car, then <TT>#f</TT>
(not the empty list) is returned.  The procedure <VAR>pred</VAR> is used for
testing equality.  If <VAR>pred</VAR> is not provided, `<SAMP>equal?</SAMP>' is used.
</P>
</DL>
<A NAME="SEC259"></A>
<H3> Set operations </H3>
<!--docid::SEC259::-->
<P>

<A NAME="SRFI-2"></A>
<HR SIZE="6">
<A NAME="SEC260"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC249"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC261"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC248"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.4.13.2 SRFI-2 </H4>
<!--docid::SEC260::-->
<P>

<CODE>(require 'srfi-2)</CODE>
<A NAME="IDX1548"></A>
</P>
<P>

<A NAME="IDX1549"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>and-let*</B> <I>claws body <small>...</small></I>
<DD><P>

<A HREF="http://srfi.schemers.org/srfi-2/srfi-2.html">http://srfi.schemers.org/srfi-2/srfi-2.html</A>
</P>
</DL>
<P>

<A NAME="SRFI-8"></A>
<HR SIZE="6">
<A NAME="SEC261"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC260"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC262"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC248"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.4.13.3 SRFI-8 </H4>
<!--docid::SEC261::-->
<P>

<CODE>(require 'srfi-8)</CODE>
<A NAME="IDX1550"></A>
</P>
<P>

<A NAME="IDX1551"></A>
</P>
<DL>
<DT><U>Special Form:</U> <B>receive</B> <I>formals expression body <small>...</small></I>
<DD><P>

<A HREF="http://srfi.schemers.org/srfi-8/srfi-8.html">http://srfi.schemers.org/srfi-8/srfi-8.html</A>
</P>
</DL>
<P>

<A NAME="SRFI-9"></A>
<HR SIZE="6">
<A NAME="SEC262"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC261"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC263"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC248"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H4> 7.4.13.4 SRFI-9 </H4>
<!--docid::SEC262::-->
<P>

<CODE>(require 'srfi-9)</CODE>
<A NAME="IDX1552"></A>
</P>
<P>

<A HREF="http://srfi.schemers.org/srfi-9/srfi-9.html">http://srfi.schemers.org/srfi-9/srfi-9.html</A>
</P>
<P>

<A NAME="IDX1553"></A>
</P>
<DL>
<DT><U>Special Form:</U> <B>define-record-type</B> <I>&lt;type-name&gt; (&lt;constructor-name&gt; &lt;field-tag&gt; ...) &lt;predicate-name&gt; &lt;field spec&gt; ...</I>
<DD><P>

Where
<TABLE><tr><td>&nbsp;</td><td class=example><pre>&lt;field-spec&gt; == (&lt;field-tag&gt; &lt;accessor-name&gt;)
             == (&lt;field-tag&gt; &lt;accessor-name&gt; &lt;modifier-name&gt;)

</pre></td></tr></table><P>

<CODE>define-record-type</CODE> is a syntax wrapper for the SLIB
<CODE>record</CODE> module.
</P>
</DL>
<P>

<A NAME="Session Support"></A>
<HR SIZE="6">
<A NAME="SEC263"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC262"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC264"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 7.5 Session Support </H2>
<!--docid::SEC263::-->
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC264">7.5.1 Repl</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Macros at top-level</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC265">7.5.2 Quick Print</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Loop-safe Output</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC266">7.5.3 Debug</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">To err is human ...</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC267">7.5.4 Breakpoints</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Pause execution</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC268">7.5.5 Tracing</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">'trace</TD></TR>
</TABLE>
<P>

<A NAME="Repl"></A>
<HR SIZE="6">
<A NAME="SEC264"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC263"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC265"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC263"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.5.1 Repl </H3>
<!--docid::SEC264::-->
<P>

<CODE>(require 'repl)</CODE>
<A NAME="IDX1554"></A>
</P>
<P>

Here is a read-eval-print-loop which, given an eval, evaluates forms.
</P>
<P>

<A NAME="IDX1555"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>repl:top-level</B> <I>repl:eval</I>
<DD><CODE>read</CODE>s, <CODE>repl:eval</CODE>s and <CODE>write</CODE>s expressions from
<CODE>(current-input-port)</CODE> to <CODE>(current-output-port)</CODE> until an
end-of-file is encountered.  <CODE>load</CODE>, <CODE>slib:eval</CODE>,
<CODE>slib:error</CODE>, and <CODE>repl:quit</CODE> dynamically bound during
<CODE>repl:top-level</CODE>.
</DL>
<P>

<A NAME="IDX1556"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>repl:quit</B>
<DD>Exits from the invocation of <CODE>repl:top-level</CODE>.
</DL>
<P>

The <CODE>repl:</CODE> procedures establish, as much as is possible to do
portably, a top level environment supporting macros.
<CODE>repl:top-level</CODE> uses <CODE>dynamic-wind</CODE> to catch error conditions
and interrupts.  If your implementation supports this you are all set.
</P>
<P>

Otherwise, if there is some way your implementation can catch error
conditions and interrupts, then have them call <CODE>slib:error</CODE>.  It
will display its arguments and reenter <CODE>repl:top-level</CODE>.
<CODE>slib:error</CODE> dynamically bound by <CODE>repl:top-level</CODE>.
</P>
<P>

To have your top level loop always use macros, add any interrupt
catching lines and the following lines to your Scheme init file:
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'macro)
<A NAME="IDX1557"></A>(require 'repl)
<A NAME="IDX1558"></A>(repl:top-level macro:eval)
</pre></td></tr></table><P>

<A NAME="Quick Print"></A>
<HR SIZE="6">
<A NAME="SEC265"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC264"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC266"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC263"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.5.2 Quick Print </H3>
<!--docid::SEC265::-->
<P>

<CODE>(require 'qp)</CODE>
<A NAME="IDX1559"></A>
</P>
<P>

When displaying error messages and warnings, it is paramount that the
output generated for circular lists and large data structures be
limited.  This section supplies a procedure to do this.  It could be
much improved.
</P>
<P>

<BLOCKQUOTE>
Notice that the neccessity for truncating output eliminates
Common-Lisp's <A HREF="slib_4.html#SEC53">4.2 Format (version 3.0)</A> from consideration; even when variables
<CODE>*print-level*</CODE> and <CODE>*print-level*</CODE> are set, huge strings and
bit-vectors are <EM>not</EM> limited.
</BLOCKQUOTE>
<P>

<A NAME="IDX1560"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>qp</B> <I>arg1 <small>...</small></I>
<DD><A NAME="IDX1561"></A>
<DT><U>Procedure:</U> <B>qpn</B> <I>arg1 <small>...</small></I>
<DD><A NAME="IDX1562"></A>
<DT><U>Procedure:</U> <B>qpr</B> <I>arg1 <small>...</small></I>
<DD><CODE>qp</CODE> writes its arguments, separated by spaces, to
<CODE>(current-output-port)</CODE>.  <CODE>qp</CODE> compresses printing by
substituting `<SAMP>...</SAMP>' for substructure it does not have sufficient
room to print.  <CODE>qpn</CODE> is like <CODE>qp</CODE> but outputs a newline
before returning.  <CODE>qpr</CODE> is like <CODE>qpn</CODE> except that it returns
its last argument.
</DL>
<P>

<A NAME="IDX1563"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>*qp-width*</B>
<DD><VAR>*qp-width*</VAR> is the largest number of characters that <CODE>qp</CODE>
should use.  If <VAR>*qp-width*</VAR> is #f, then all items will be
<CODE>write</CODE>n.  If <VAR>*qp-width*</VAR> is 0, then all items except
procedures will be <CODE>write</CODE>n; procedures will be indicated by
`<SAMP>#[proc]</SAMP>'.
</DL>
<P>

<A NAME="Debug"></A>
<HR SIZE="6">
<A NAME="SEC266"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC265"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC267"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC263"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.5.3 Debug </H3>
<!--docid::SEC266::-->
<P>

<CODE>(require 'debug)</CODE>
<A NAME="IDX1564"></A>
</P>
<P>

Requiring <CODE>debug</CODE> automatically requires <CODE>trace</CODE> and
<CODE>break</CODE>.
</P>
<P>

An application with its own datatypes may want to substitute its own
printer for <CODE>qp</CODE>.  This example shows how to do this:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define qpn (lambda args) <small>...</small>)
(provide 'qp)
(require 'debug)
<A NAME="IDX1565"></A></pre></td></tr></table><P>

<A NAME="IDX1566"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>trace-all</B> <I>file <small>...</small></I>
<DD>Traces (see section <A HREF="slib_7.html#SEC268">7.5.5 Tracing</A>) all procedures <CODE>define</CODE>d at top-level in
`<TT>file</TT>' <small>...</small>.
<P>

<A NAME="IDX1567"></A>
<DT><U>Procedure:</U> <B>track-all</B> <I>file <small>...</small></I>
<DD>Tracks (see section <A HREF="slib_7.html#SEC268">7.5.5 Tracing</A>) all procedures <CODE>define</CODE>d at top-level in
`<TT>file</TT>' <small>...</small>.
</P>
<P>

<A NAME="IDX1568"></A>
<DT><U>Procedure:</U> <B>stack-all</B> <I>file <small>...</small></I>
<DD>Stacks (see section <A HREF="slib_7.html#SEC268">7.5.5 Tracing</A>) all procedures <CODE>define</CODE>d at top-level in
`<TT>file</TT>' <small>...</small>.
</P>
</DL>
<P>

<A NAME="IDX1569"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>break-all</B> <I>file <small>...</small></I>
<DD>Breakpoints (see section <A HREF="slib_7.html#SEC267">7.5.4 Breakpoints</A>) all procedures <CODE>define</CODE>d at
top-level in `<TT>file</TT>' <small>...</small>.
</DL>
<P>

<A NAME="Breakpoints"></A>
<HR SIZE="6">
<A NAME="SEC267"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC266"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC268"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC263"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.5.4 Breakpoints </H3>
<!--docid::SEC267::-->
<P>

<CODE>(require 'break)</CODE>
<A NAME="IDX1570"></A>
</P>
<P>

<A NAME="IDX1571"></A>
</P>
<DL>
<DT><U>Function:</U> <B>init-debug</B>
<DD>If your Scheme implementation does not support <CODE>break</CODE> or
<CODE>abort</CODE>, a message will appear when you <CODE>(require 'break)</CODE> or
<A NAME="IDX1572"></A>
<CODE>(require 'debug)</CODE> telling you to type <CODE>(init-debug)</CODE>.  This
<A NAME="IDX1573"></A>
is in order to establish a top-level continuation.  Typing
<CODE>(init-debug)</CODE> at top level sets up a continuation for
<CODE>break</CODE>.
</DL>
<P>

<A NAME="IDX1574"></A>
</P>
<DL>
<DT><U>Function:</U> <B>breakpoint</B> <I>arg1 <small>...</small></I>
<DD>Returns from the top level continuation and pushes the continuation from
which it was called on a continuation stack.
</DL>
<P>

<A NAME="IDX1575"></A>
</P>
<DL>
<DT><U>Function:</U> <B>continue</B>
<DD>Pops the topmost continuation off of the continuation stack and returns
an unspecified value to it.
<P>

<A NAME="IDX1576"></A>
<DT><U>Function:</U> <B>continue</B> <I>arg1 <small>...</small></I>
<DD>Pops the topmost continuation off of the continuation stack and returns
<VAR>arg1</VAR> <small>...</small> to it.
</P>
</DL>
<P>

<A NAME="IDX1577"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>break</B> <I>proc1 <small>...</small></I>
<DD>Redefines the top-level named procedures given as arguments so that
<CODE>breakpoint</CODE> is called before calling <VAR>proc1</VAR> <small>...</small>.
<A NAME="IDX1578"></A>
<DT><U>Macro:</U> <B>break</B>
<DD>With no arguments, makes sure that all the currently broken identifiers
are broken (even if those identifiers have been redefined) and returns a
list of the broken identifiers.
</DL>
<P>

<A NAME="IDX1579"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>unbreak</B> <I>proc1 <small>...</small></I>
<DD>Turns breakpoints off for its arguments.
<A NAME="IDX1580"></A>
<DT><U>Macro:</U> <B>unbreak</B>
<DD>With no arguments, unbreaks all currently broken identifiers and returns
a list of these formerly broken identifiers.
</DL>
<P>

These are <EM>procedures</EM> for breaking.  If defmacros are not natively
supported by your implementation, these might be more convenient to use.
</P>
<P>

<A NAME="IDX1581"></A>
</P>
<DL>
<DT><U>Function:</U> <B>breakf</B> <I>proc</I>
<DD><A NAME="IDX1582"></A>
<DT><U>Function:</U> <B>breakf</B> <I>proc name</I>
<DD>To break, type
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! <VAR>symbol</VAR> (breakf <VAR>symbol</VAR>))
</pre></td></tr></table>or
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! <VAR>symbol</VAR> (breakf <VAR>symbol</VAR> '<VAR>symbol</VAR>))
</pre></td></tr></table>or
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define <VAR>symbol</VAR> (breakf <VAR>function</VAR>))
</pre></td></tr></table>or
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define <VAR>symbol</VAR> (breakf <VAR>function</VAR> '<VAR>symbol</VAR>))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1583"></A>
</P>
<DL>
<DT><U>Function:</U> <B>unbreakf</B> <I>proc</I>
<DD>To unbreak, type
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! <VAR>symbol</VAR> (unbreakf <VAR>symbol</VAR>))
</pre></td></tr></table></DL>
<P>

<A NAME="Trace"></A>
<HR SIZE="6">
<A NAME="SEC268"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC267"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC269"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC263"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.5.5 Tracing </H3>
<!--docid::SEC268::-->
<P>

<CODE>(require 'trace)</CODE>
<A NAME="IDX1584"></A>
</P>
<P>

This feature provides three ways to monitor procedure invocations:
</P>
<P>

</P>
<DL COMPACT>
<DT>stack
<DD>Pushes the procedure-name when the procedure is called; pops when it
returns.
<DT>track
<DD>Pushes the procedure-name and arguments when the procedure is called;
pops when it returns.
<DT>trace
<DD>Pushes the procedure-name and prints `<SAMP>CALL <VAR>procedure-name</VAR>
<VAR>arg1</VAR> <small>...</small></SAMP>' when the procdure is called; pops and prints
`<SAMP>RETN <VAR>procedure-name</VAR> <VAR>value</VAR></SAMP>' when the procedure returns.
</DL>
<P>

<A NAME="IDX1585"></A>
</P>
<DL>
<DT><U>Variable:</U> <B>debug:max-count</B>
<DD>If a traced procedure calls itself or untraced procedures which call it,
stack, track, and trace will limit the number of stack pushes to
<VAR>debug:max-count</VAR>.
</DL>
<P>

<A NAME="IDX1586"></A>
</P>
<DL>
<DT><U>Function:</U> <B>print-call-stack</B>
<DD><A NAME="IDX1587"></A>
<DT><U>Function:</U> <B>print-call-stack</B> <I>port</I>
<DD>Prints the call-stack to <VAR>port</VAR> or the current-error-port.
</DL>
<P>

<A NAME="IDX1588"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>trace</B> <I>proc1 <small>...</small></I>
<DD>Traces the top-level named procedures given as arguments.
<A NAME="IDX1589"></A>
<DT><U>Macro:</U> <B>trace</B>
<DD>With no arguments, makes sure that all the currently traced identifiers
are traced (even if those identifiers have been redefined) and returns a
list of the traced identifiers.
</DL>
<P>

<A NAME="IDX1590"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>track</B> <I>proc1 <small>...</small></I>
<DD>Traces the top-level named procedures given as arguments.
<A NAME="IDX1591"></A>
<DT><U>Macro:</U> <B>track</B>
<DD>With no arguments, makes sure that all the currently tracked identifiers
are tracked (even if those identifiers have been redefined) and returns
a list of the tracked identifiers.
</DL>
<P>

<A NAME="IDX1592"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>stack</B> <I>proc1 <small>...</small></I>
<DD>Traces the top-level named procedures given as arguments.
<A NAME="IDX1593"></A>
<DT><U>Macro:</U> <B>stack</B>
<DD>With no arguments, makes sure that all the currently stacked identifiers
are stacked (even if those identifiers have been redefined) and returns
a list of the stacked identifiers.
</DL>
<P>

<A NAME="IDX1594"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>untrace</B> <I>proc1 <small>...</small></I>
<DD>Turns tracing, tracking, and  off for its arguments.
<A NAME="IDX1595"></A>
<DT><U>Macro:</U> <B>untrace</B>
<DD>With no arguments, untraces all currently traced identifiers and returns
a list of these formerly traced identifiers.
</DL>
<P>

<A NAME="IDX1596"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>untrack</B> <I>proc1 <small>...</small></I>
<DD>Turns tracing, tracking, and  off for its arguments.
<A NAME="IDX1597"></A>
<DT><U>Macro:</U> <B>untrack</B>
<DD>With no arguments, untracks all currently tracked identifiers and returns
a list of these formerly tracked identifiers.
</DL>
<P>

<A NAME="IDX1598"></A>
</P>
<DL>
<DT><U>Macro:</U> <B>unstack</B> <I>proc1 <small>...</small></I>
<DD>Turns tracing, stacking, and  off for its arguments.
<A NAME="IDX1599"></A>
<DT><U>Macro:</U> <B>unstack</B>
<DD>With no arguments, unstacks all currently stacked identifiers and returns
a list of these formerly stacked identifiers.
</DL>
<P>

These are <EM>procedures</EM> for tracing.  If defmacros are not natively
supported by your implementation, these might be more convenient to use.
</P>
<P>

<A NAME="IDX1600"></A>
</P>
<DL>
<DT><U>Function:</U> <B>tracef</B> <I>proc</I>
<DD><A NAME="IDX1601"></A>
<DT><U>Function:</U> <B>tracef</B> <I>proc name</I>
<DD><A NAME="IDX1602"></A>
<DT><U>Function:</U> <B>trackf</B> <I>proc</I>
<DD><A NAME="IDX1603"></A>
<DT><U>Function:</U> <B>trackf</B> <I>proc name</I>
<DD><A NAME="IDX1604"></A>
<DT><U>Function:</U> <B>stackf</B> <I>proc</I>
<DD><A NAME="IDX1605"></A>
<DT><U>Function:</U> <B>stackf</B> <I>proc name</I>
<DD>To trace, type
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! <VAR>symbol</VAR> (tracef <VAR>symbol</VAR>))
</pre></td></tr></table>or
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! <VAR>symbol</VAR> (tracef <VAR>symbol</VAR> '<VAR>symbol</VAR>))
</pre></td></tr></table>or
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define <VAR>symbol</VAR> (tracef <VAR>function</VAR>))
</pre></td></tr></table>or
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(define <VAR>symbol</VAR> (tracef <VAR>function</VAR> '<VAR>symbol</VAR>))
</pre></td></tr></table></DL>
<P>

<A NAME="IDX1606"></A>
</P>
<DL>
<DT><U>Function:</U> <B>untracef</B> <I>proc</I>
<DD>Removes tracing, tracking, or stacking for <VAR>proc</VAR>.
To untrace, type
<TABLE><tr><td>&nbsp;</td><td class=example><pre>(set! <VAR>symbol</VAR> (untracef <VAR>symbol</VAR>))
</pre></td></tr></table></DL>
<P>

<A NAME="System Interface"></A>
<HR SIZE="6">
<A NAME="SEC269"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC268"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC270"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 7.6 System Interface </H2>
<!--docid::SEC269::-->
<P>

If <CODE>(provided? 'getenv)</CODE>:
</P>
<P>

<A NAME="IDX1607"></A>
</P>
<DL>
<DT><U>Function:</U> <B>getenv</B> <I>name</I>
<DD>Looks up <VAR>name</VAR>, a string, in the program environment.  If <VAR>name</VAR> is
found a string of its value is returned.  Otherwise, <CODE>#f</CODE> is returned.
</DL>
<P>

If <CODE>(provided? 'system)</CODE>:
</P>
<P>

<A NAME="IDX1608"></A>
</P>
<DL>
<DT><U>Function:</U> <B>system</B> <I>command-string</I>
<DD>Executes the <VAR>command-string</VAR> on the computer and returns the
integer status code.
</DL>
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC270">7.6.1 Directories</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC271">7.6.2 Transactions</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="slib_7.html#SEC275">7.6.3 CVS</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<P>

<A NAME="Directories"></A>
<HR SIZE="6">
<A NAME="SEC270"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC269"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC271"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC269"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.6.1 Directories </H3>
<!--docid::SEC270::-->
<P>

<CODE>(require 'directory)</CODE>
<A NAME="IDX1609"></A>
</P>
<P>

<A NAME="IDX1610"></A>
</P>
<DL>
<DT><U>Function:</U> <B>current-directory</B>
<DD><P>

<CODE>current-directory</CODE> returns a string containing the absolute file
name representing the current working directory.  If this string
cannot be obtained, #f is returned.
</P>
<P>

If <CODE>current-directory</CODE> cannot be supported by the platform, then #f is returned.
</P>
</DL>
<P>

<A NAME="IDX1611"></A>
</P>
<DL>
<DT><U>Function:</U> <B>make-directory</B> <I>name</I>
<DD><P>

Creates a sub-directory <VAR>name</VAR> of the current-directory.  If
successful, <CODE>make-directory</CODE> returns #t; otherwise #f.
</P>
</DL>
<P>

<A NAME="IDX1612"></A>
</P>
<DL>
<DT><U>Function:</U> <B>directory-for-each</B> <I>proc directory</I>
<DD><P>

<VAR>proc</VAR> must be a procedure taking one argument.
`<SAMP>Directory-For-Each</SAMP>' applies <VAR>proc</VAR> to the (string) name of
each file in <VAR>directory</VAR>.  The dynamic order in which <VAR>proc</VAR> is
applied to the filenames is unspecified.  The value returned by
`<SAMP>directory-for-each</SAMP>' is unspecified.
</P>
<P>

<A NAME="IDX1613"></A>
<DT><U>Function:</U> <B>directory-for-each</B> <I>proc directory pred</I>
<DD>Applies <VAR>proc</VAR> only to those filenames for which the procedure
<VAR>pred</VAR> returns a non-false value.
</P>
<P>

<A NAME="IDX1614"></A>
<DT><U>Function:</U> <B>directory-for-each</B> <I>proc directory match</I>
<DD>Applies <VAR>proc</VAR> only to those filenames for which
<CODE>(filename:match?? <VAR>match</VAR>)</CODE> would return a non-false value
(see section `Filenames' in <CITE>SLIB</CITE>).
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>(require 'directory)
(directory-for-each print &quot;.&quot; &quot;[A-Z]*.scm&quot;)
-|
&quot;Bev2slib.scm&quot;
&quot;Template.scm&quot;
</pre></td></tr></table></DL>
<P>

<A NAME="Transactions"></A>
<HR SIZE="6">
<A NAME="SEC271"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC270"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC275"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC269"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.6.2 Transactions </H3>
<!--docid::SEC271::-->
<P>

If <CODE>system</CODE> is provided by the Scheme implementation, the
<EM>transact</EM> package provides functions for file-locking and
file-replacement transactions.
</P>
<P>

<CODE>(require 'transact)</CODE>
<A NAME="IDX1615"></A>
</P>
<P>

<A NAME="SEC272"></A>
<H4> File Locking </H4>
<!--docid::SEC272::-->
<P>

Unix file-locking is focussed on write permissions for segments of a
existing file.  While this might be employed for (binary) database
access, it is not used for everyday contention (between users) for
text files.
</P>
<P>

Microsoft has several file-locking protocols.  Their model denies
write access to a file if any reader has it open.  This is too
restrictive.  Write access is denied even when the reader has
reached end-of-file.  And tracking read access (which is much more
common than write access) causes havoc when remote hosts crash or
disconnect.
</P>
<P>

It is bizarre that the concept of multi-user contention for
modifying files has not been adequately addressed by either of the
large operating system development efforts.  There is further irony
that both camps support contention detection and resolution only
through weak conventions of some their document editing programs.
</P>
<P>

<A NAME="IDX1616"></A>
The <EM>file-lock</EM> procedures implement a transaction method for file
<A NAME="IDX1617"></A>
replacement compatible with the methods used by the GNU <EM>emacs</EM>
<A NAME="IDX1618"></A>
text editor on Unix systems and the Microsoft <EM>Word</EM> editor.
<A NAME="IDX1619"></A>
<A NAME="IDX1620"></A>
</P>
<P>

<A NAME="IDX1621"></A>
Both protocols employ what I term a <EM>certificate</EM> containing the
<A NAME="IDX1622"></A>
user, hostname, time, and (on Unix) process-id.
Intent to replace <VAR>file</VAR> is indicated by adding to <VAR>file</VAR>'s
directory a certificate object whose name is derived from
<VAR>file</VAR>.
</P>
<P>

The Microsoft Word certificate is contained in a 162 byte file named
for the visited <VAR>file</VAR> with a `<SAMP>~$</SAMP>' prefix.
Emacs/Unix creates a symbolic link to a certificate named for the
visited <VAR>file</VAR> prefixed with `<SAMP>.#</SAMP>'.
Because Unix systems can import Microsoft file systems, these
routines maintain and check both Emacs and Word certificates.
</P>
<P>

<A NAME="IDX1623"></A>
</P>
<DL>
<DT><U>Function:</U> <B>file-lock-owner</B> <I>path</I>
<DD><P>

Returns the string `<SAMP><VAR>user</VAR>@<VAR>hostname</VAR></SAMP>' associated with
the lock owner of file <VAR>path</VAR> if locked; and #f otherwise.
</P>
</DL>
<P>

<A NAME="IDX1624"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>file-lock!</B> <I>path email</I>
<DD><P>

<A NAME="IDX1625"></A>
<DT><U>Procedure:</U> <B>file-lock!</B> <I>path</I>
<DD></P>
<P>

<VAR>path</VAR> must be a string naming the file to be locked.  If supplied, <VAR>email</VAR>
must be a string formatted as `<SAMP><VAR>user</VAR>@<VAR>hostname</VAR></SAMP>'.  If
absent, <VAR>email</VAR> defaults to the value returned by <CODE>user-email-address</CODE>.
</P>
<P>

If <VAR>path</VAR> is already locked, then <CODE>file-lock!</CODE> returns `<SAMP>#f</SAMP>'.  If <VAR>path</VAR> is
unlocked, then <CODE>file-lock!</CODE> returns the certificate string associated with the
new lock for file <VAR>path</VAR>.
</P>
</DL>
<P>

<A NAME="IDX1626"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>file-unlock!</B> <I>path certificate</I>
<DD><P>

<VAR>path</VAR> must be a string naming the file to be unlocked.  <VAR>certificate</VAR> must be the
string returned by <CODE>file-lock!</CODE> for <VAR>path</VAR>.
</P>
<P>

If <VAR>path</VAR> is locked with <VAR>certificate</VAR>, then <CODE>file-unlock!</CODE> removes the locks and returns
`<SAMP>#t</SAMP>'.  Otherwise, <CODE>file-unlock!</CODE> leaves the file system unaltered and returns
`<SAMP>#f</SAMP>'.
</P>
</DL>
<A NAME="SEC273"></A>
<H4> File Transactions </H4>
<!--docid::SEC273::-->
<P>

<A NAME="IDX1627"></A>
</P>
<DL>
<DT><U>Function:</U> <B>emacs:backup-name</B> <I>path backup-style</I>
<DD><P>

<VAR>path</VAR> must be a string.  <VAR>backup-style</VAR> must be a symbol.  Depending on <VAR>backup-style</VAR>, <CODE>emacs:backup-name</CODE>
returns:
</P>
<DL COMPACT>
<DT>none
<DD>#f
<DT>simple
<DD>the string &quot;<VAR>path</VAR>~&quot;
<DT>numbered
<DD>the string &quot;<VAR>path</VAR>.~<VAR>n</VAR>~&quot;, where <VAR>n</VAR> is one greater than the
highest number appearing in a filename matching &quot;<VAR>path</VAR>.~*~&quot;.  <VAR>n</VAR>
defauls to 1 when no filename matches.
<DT>existing
<DD>the string &quot;<VAR>path</VAR>.~<VAR>n</VAR>~&quot; if a numbered backup already exists in
this directory; otherwise. &quot;<VAR>path</VAR>~&quot;
<DT>orig
<DD>the string &quot;<VAR>path</VAR>.orig&quot;
<DT>bak
<DD>the string &quot;<VAR>path</VAR>.bak&quot;
</DL>
</DL>
<P>

<A NAME="IDX1628"></A>
</P>
<DL>
<DT><U>Function:</U> <B>transact-file-replacement</B> <I>proc path backup-style certificate</I>
<DD><P>

<A NAME="IDX1629"></A>
<DT><U>Function:</U> <B>transact-file-replacement</B> <I>proc path backup-style</I>
<DD></P>
<P>

<A NAME="IDX1630"></A>
<DT><U>Function:</U> <B>transact-file-replacement</B> <I>proc path</I>
<DD></P>
<P>

<VAR>path</VAR> must be a string naming an existing file.  <VAR>backup-style</VAR> is one of the
symbols none, simple, numbered, existing, orig,
bak or #f; with meanings described above; or a string naming
the location of a backup file.  <VAR>backup-style</VAR> defaults to #f.  If supplied,
<VAR>certificate</VAR> is the certificate with which <VAR>path</VAR> is locked.
</P>
<P>

<VAR>proc</VAR> must be a procedure taking two string arguments:
<UL>
<LI>
<VAR>path</VAR>, the original filename (to be read); and
<LI>
a temporary file-name.
</UL>
<P>

If <VAR>path</VAR> is locked by other than <VAR>certificate</VAR>, or if <VAR>certificate</VAR> is supplied and <VAR>path</VAR> is not
locked, then <CODE>transact-file-replacement</CODE> returns #f.  If <VAR>certificate</VAR> is not supplied, then, <CODE>transact-file-replacement</CODE> creates
temporary (Emacs and Word) locks for <VAR>path</VAR> during the transaction.  The
lock status of <VAR>path</VAR> will be restored before <CODE>transact-file-replacement</CODE> returns.
</P>
<P>

<CODE>transact-file-replacement</CODE> calls <VAR>proc</VAR> with <VAR>path</VAR> (which should not be modified) and a temporary
file path to be written.
If <VAR>proc</VAR> returns any value other than #t, then the file named by <VAR>path</VAR>
is not altered and <CODE>transact-file-replacement</CODE> returns #f.
Otherwise, <CODE>emacs:backup-name</CODE> is called with <VAR>path</VAR> and <VAR>backup-style</VAR>.  If it
returns a string, then <VAR>path</VAR> is renamed to it.
</P>
<P>

Finally, the temporary file is renamed <VAR>path</VAR>.
<CODE>transact-file-replacement</CODE> returns #t if <VAR>path</VAR> was successfully replaced; and #f otherwise.
</P>
</DL>
<A NAME="SEC274"></A>
<H4> Identification </H4>
<!--docid::SEC274::-->
<P>

<A NAME="IDX1631"></A>
</P>
<DL>
<DT><U>Function:</U> <B>user-email-address</B>
<DD><P>

<CODE>user-email-address</CODE> returns a string of the form `<SAMP>username@hostname</SAMP>'.  If
this e-mail address cannot be obtained, #f is returned.
</P>
</DL>
<P>

<A NAME="CVS"></A>
<HR SIZE="6">
<A NAME="SEC275"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC271"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC276"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC269"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 7.6.3 CVS </H3>
<!--docid::SEC275::-->
<P>

<CODE>(require 'cvs)</CODE>
<A NAME="IDX1632"></A>
</P>
<P>

<A NAME="IDX1633"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cvs-files</B> <I>directory/</I>
<DD>Returns a list of the local pathnames (with prefix <VAR>directory/</VAR>) of all
CVS controlled files in <VAR>directory/</VAR> and in <VAR>directory/</VAR>'s subdirectories.
</DL>
<P>

<A NAME="IDX1634"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cvs-directories</B> <I>directory/</I>
<DD>Returns a list of all of <VAR>directory/</VAR> and all <VAR>directory/</VAR>'s CVS controlled
subdirectories.
</DL>
<P>

<A NAME="IDX1635"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cvs-root</B> <I>path/</I>
<DD>Returns the (string) contents of <VAR>path/</VAR>CVS/Root;
or <CODE>(getenv &quot;CVSROOT&quot;)</CODE> if Root doesn't exist.
</DL>
<P>

<A NAME="IDX1636"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cvs-repository</B> <I>directory/</I>
<DD>Returns the (string) contents of <VAR>directory/</VAR>CVS/Root appended
with <VAR>directory/</VAR>CVS/Repository; or #f if <VAR>directory/</VAR>CVS/Repository
doesn't exist.
</DL>
<P>

<A NAME="IDX1637"></A>
</P>
<DL>
<DT><U>Procedure:</U> <B>cvs-set-root!</B> <I>new-root directory/</I>
<DD><P>

Writes <VAR>new-root</VAR> to file CVS/Root of <VAR>directory/</VAR> and all its subdirectories.
</P>
</DL>
<P>

<A NAME="IDX1638"></A>
</P>
<DL>
<DT><U>Function:</U> <B>cvs-vet</B> <I>directory/</I>
<DD><P>

Signals an error if CVS/Repository or CVS/Root files in <VAR>directory/</VAR> or any
subdirectory do not match.
</P>
</DL>
<P>

<A NAME="Extra-SLIB Packages"></A>
<HR SIZE="6">
<A NAME="SEC276"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC275"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 7.7 Extra-SLIB Packages </H2>
<!--docid::SEC276::-->
<P>

Several Scheme packages have been written using SLIB.  There are several
reasons why a package might not be included in the SLIB distribution:
<UL>
<LI>
Because it requires special hardware or software which is not universal.
<LI>
Because it is large and of limited interest to most Scheme users.
<LI>
Because it has copying terms different enough from the other SLIB
packages that its inclusion would cause confusion.
<LI>
Because it is an application program, rather than a library module.
<LI>
Because I have been too busy to integrate it.
</UL>
<P>

Once an optional package is installed (and an entry added to
<CODE>*catalog*</CODE>, the <CODE>require</CODE> mechanism allows it to be called up
and used as easily as any other SLIB package.  Some optional packages
(for which <CODE>*catalog*</CODE> already has entries) available from SLIB
sites are:
</P>
<P>

</P>
<DL COMPACT>
<DT>SLIB-PSD
<DD>is a portable debugger for Scheme (requires emacs editor).
<P>

&lt;A HREF=&quot;http://swissnet.ai.mit.edu/ftpdir/scm/slib-psd1-3.tar.gz&quot;&gt;
http://swissnet.ai.mit.edu/ftpdir/scm/slib-psd1-3.tar.gz
&lt;/A&gt;
</P>
<P>

swissnet.ai.mit.edu:/pub/scm/slib-psd1-3.tar.gz
</P>
<P>

ftp.maths.tcd.ie:pub/bosullvn/jacal/slib-psd1-3.tar.gz
</P>
<P>

ftp.cs.indiana.edu:/pub/scheme-repository/utl/slib-psd1-3.tar.gz
</P>
<P>

With PSD, you can run a Scheme program in an Emacs buffer, set
breakpoints, single step evaluation and access and modify the program's
variables. It works by instrumenting the original source code, so it
should run with any R4RS compliant Scheme. It has been tested with SCM,
Elk 1.5, and the sci interpreter in the Scheme-&gt;C system, but should
work with other Schemes with a minimal amount of porting, if at
all. Includes documentation and user's manual.  Written by Pertti
Kellom\&quot;aki, pk @ cs.tut.fi.  The Lisp Pointers article describing PSD
(Lisp Pointers VI(1):15-23, January-March 1993) is available as
&lt;A HREF=&quot;http://www.cs.tut.fi/staff/pk/scheme/psd/article/article.html&quot;&gt;
http://www.cs.tut.fi/staff/pk/scheme/psd/article/article.html
&lt;/A&gt;
</P>
<P>

</P>
<DT>SCHELOG
<DD>is an embedding of Prolog in Scheme.<BR>
&lt;A HREF=&quot;http://www.ccs.neu.edu/~dorai/schelog/schelog.html&quot;&gt;
http://www.ccs.neu.edu/~dorai/schelog/schelog.html
&lt;/A&gt;
<P>

</P>
<DT>JFILTER
<DD>is a Scheme program which converts text among the JIS, EUC, and
Shift-JIS Japanese character sets.<BR>
&lt;A HREF=&quot;http://www.sci.toyama-u.ac.jp/~iwao/Scheme/Jfilter/index.html&quot;&gt;
http://www.sci.toyama-u.ac.jp/~iwao/Scheme/Jfilter/index.html
&lt;/A&gt;
</DL>
<P>

<A NAME="About SLIB"></A>
<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_7.html#SEC183"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_8.html#SEC277"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="slib_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Steve Langasek</I> on <I>January, 10 2005</I>
using <A HREF="http://texi2html.cvshome.org"><I>texi2html</I></A>
</FONT>

</BODY>
</HTML>