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
|
@define(codef, FaceCode T, size 11)
@comment{In my original scribe conversion of the ascii xlisp documentation, I used
times roman fonts for xlisp function names and code text in general. To be
consistent with Nyquist documentation, I have changed the code font to xlcode
which is defined here. If this turns out to be a problem, redefine xlcode to
use the regular FaceCode. -RBD}
@define(xlcode, FaceCode T, size 11)
@textform(pragma=[])
@section(Introduction)
XLISP is an experimental programming language combining some of
the features of Common Lisp with an object-oriented extension
capability. It was implemented to allow experimentation with
object-oriented programming on small computers.
Implementations of XLISP run on virtually every operating system.
XLISP is completely written in the programming language
C and is easily extended with user written built-in functions
and classes. It is available in source form to non-commercial
users.
Many Common Lisp functions are built into XLISP. In addition,
XLISP defines the objects Object and Class as primitives.
Object is the only class that has no superclass and hence is
the root of the class hierarchy tree. Class is the class of
which all classes are instances (it is the only object that is
an instance of itself).
This document is a brief description of XLISP. It assumes some
knowledge of LISP and some understanding of the concepts of
object-oriented programming.
I recommend the book @i(Lisp) by Winston and Horn and published by
Addison Wesley for learning Lisp. The first edition of this
book is based on MacLisp and the second edition is based on
Common Lisp.
You will probably also need a copy of @i(Common Lisp: The
Language) by Guy L. Steele, Jr., published by Digital Press to
use as a reference for some of the Common Lisp functions that
are described only briefly in this document.
@section(A Note From The Author)
If you have any problems with XLISP, feel free to contact me [me being David Betz - RBD] for
help or advice. Please remember that since XLISP is available
in source form in a high level language, many users [e.g. that Dannenberg fellow - RBD] have been
making versions available on a variety of machines. If you call
to report a problem with a specific version, I may not be able
to help you if that version runs on a machine to which I don't
have access. Please have the version number of the version that
you are running readily accessible before calling me.
If you find a bug in XLISP, first try to fix the bug yourself
using the source code provided. If you are successful in fixing
the bug, send the bug report along with the fix to me. If you
don't have access to a C compiler or are unable to fix a bug,
please send the bug report to me and I'll try to fix it.
Any suggestions for improvements will be welcomed. Feel free to
extend the language in whatever way suits your needs. However,
PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME
FIRST!! I would like to be the clearing house for new features
added to XLISP. If you want to add features for your own
personal use, go ahead. But, if you want to distribute your
enhanced version, contact me first. Please remember that the
goal of XLISP is to provide a language to learn and experiment
with LISP and object-oriented programming on small computers. I
don't want it to get so big that it requires megabytes of memory
to run.
@section(XLISP Command Loop)@index(XLISP Command Loop)@index(Command Loop)
When XLISP is started, it first tries to load the workspace
@code(xlisp.wks) from the current directory. If that file doesn't
exist, XLISP builds an initial workspace, empty except for the
built-in functions and symbols.
Then XLISP attempts to load @code(init.lsp) from the current
directory. It then loads any files named as parameters on the
command line (after appending @code(.lsp) to their names).
XLISP then issues the following prompt:
@begin(example)
>
@end(example)
This indicates that XLISP is waiting for an expression to be
typed.
When a complete expression has been entered, XLISP attempts to
evaluate that expression. If the expression evaluates
successfully, XLISP prints the result and then returns to the
initial prompt waiting for another expression to be typed.
@section(Special Characters)@index(control characters, XLISP)
When XLISP is running from a console, some control characters invoke operations:
@begin(itemize)
Backspace and Delete characters erase the previous character on the input line (if any).
Control-U erases the entire input line.
Control-C executes the TOP-LEVEL function.
Control-G executes the CLEAN-UP function.
Control-P executes the CONTINUE function.
Control-B stops execution and enters the break command loop. Execution can be continued by typing Control-P or (CONTINUE).
Control-E turns on character echoing (Linux and Mac OS X only).
Control-F turns off character echoing (Linux and Mac OS X only).
Control-T evaluates the INFO function.
@end(itemize)
@section(Break Command Loop)@index(break)
When XLISP encounters an error while evaluating an expression,
it attempts to handle the error in the following way:
If the symbol @xlcode(*breakenable*@index(*breakenable*)) is
true, the message corresponding to the error is printed. If
the error is correctable, the correction message is printed.
If the symbol @xlcode(*tracenable*@index(*tracenable*)) is true, a trace back is printed.
The number of entries printed depends on the value of the symbol
@xlcode(*tracelimit*@index(*tracelimit*)). If this symbol is set to something other than a
number, the entire trace back stack is printed.
XLISP then enters a read/eval/print loop to allow the user to
examine the state of the interpreter in the context of the
error. This loop differs from the normal top-level
read/eval/print loop in that if the user invokes the function
@xlcode(continue), XLISP will continue from a correctable error. If
the user invokes the function @xlcode(clean-up), XLISP will abort the
break loop and return to the top level or the next lower
numbered break loop. When in a break loop, XLISP prefixes the
break level to the normal prompt.
If the symbol @xlcode(*breakenable*@index(*breakenable*)) is @xlcode(nil), XLISP looks for a
surrounding errset function. If one is found, XLISP examines
the value of the print flag. If this flag is true, the error
message is printed. In any case, XLISP causes the errset
function call to return @xlcode(nil).
If there is no surrounding errset function, XLISP prints the
error message and returns to the top level.
@section(Data Types)@index(XLISP Data Types)@index(Data Types)
There are several different data types available to XLISP
programmers.
@begin(itemize)
lists
symbols
strings
integers
characters
floats
objects
arrays
streams
subrs (built-in functions)
fsubrs (special forms)
closures (user defined functions)
@end(itemize)
@section(The Evaluator)@index(evaluator)@index(XLISP evaluator)
The process of evaluation in XLISP:
@begin(itemize)
Strings, integers, characters, floats, objects, arrays, streams,
subrs, fsubrs and closures evaluate to themselves.
Symbols act as variables and are evaluated by retrieving the
value associated with their current binding.
Lists are evaluated by examining the first element of the list
and then taking one of the following actions:
@begin(itemize)
If it is a symbol, the functional binding of the symbol is
retrieved.
If it is a lambda expression, a closure is constructed for
the function described by the lambda expression.
If it is a subr, fsubr or closure, it stands for itself.
Any other value is an error.
@end(itemize)
Then, the value produced by the previous step is examined:
@begin(itemize)
If it is a subr or closure, the remaining list elements are
evaluated and the subr or closure is called with these
evaluated expressions as arguments.
If it is an fsubr, the fsubr is called using the remaining
list elements as arguments (unevaluated).
If it is a macro, the macro is expanded using the remaining
list elements as arguments (unevaluated). The macro
expansion is then evaluated in place of the original macro
call.
@end(itemize)
@end(itemize)
@section(Lexical Conventions)@index(Lexical conventions)@index(XLISP Lexical Conventions)
The following conventions must be followed when entering XLISP
programs:
Comments in XLISP code begin with a semi-colon character and
continue to the end of the line.
Symbol names in XLISP can consist of any sequence of non-blank
printable characters except the following:
@begin(example)
( ) ' ` , " ;
@end(example)
Uppercase and lowercase characters are not distinguished within
symbol names. All lowercase characters are mapped to uppercase
on input.
Integer literals consist of a sequence of digits optionally
beginning with a @code(+) or @code(-). The range of values an integer can
represent is limited by the size of a C @code(long) on the machine on
which XLISP is running.
Floating point literals consist of a sequence of digits
optionally beginning with a @code(+) or @code(-) and including an embedded
decimal point. The range of values a floating point number can
represent is limited by the size of a C @code(float) (@code(double) on
machines with 32 bit addresses) on the machine on which XLISP is
running.
Literal strings are sequences of characters surrounded by double
quotes. Within quoted strings the ``@code(\)'' character is used to
allow non-printable characters to be included. The codes
recognized are:
@begin(itemize)
@code(\\) means the character ``@code(\)''
@code(\n) means newline
@code(\t) means tab
@code(\r) means return
@code(\f) means form feed
@code(\nnn) means the character whose octal code is nnn
@end(itemize)
@section(Readtables)@index(Readtables)
The behavior of the reader is controlled by a data structure
called a @i(readtable). The reader uses the symbol @xlcode(*readtable*@index(*readtable*)) to
locate the current readtable. This table controls the
interpretation of input characters. It is an array with 128
entries, one for each of the ASCII character codes. Each entry
contains one of the following things:
@begin(itemize)
@xlcode(NIL) @itemsep Indicating an invalid character
@xlcode(:CONSTITUENT) @itemsep Indicating a symbol constituent
@xlcode(:WHITE-SPACE) @itemsep Indicating a whitespace character
@xlcode[(:TMACRO . @i(fun))] @itemsep Terminating readmacro
@xlcode[(:NMACRO . @i(fun))] @itemsep Non-terminating readmacro
@xlcode(:SESCAPE) @itemsep Single escape character ('\')
@xlcode(:MESCAPE) @itemsep Multiple escape character ('|')
@end(itemize)
In the case of @xlcode(:TMACRO) and @xlcode(:NMACRO), the @i(fun) component is a
function. This can either be a built-in readmacro function or a
lambda expression. The function should take two parameters.
The first is the input stream and the second is the character
that caused the invocation of the readmacro. The readmacro
function should return @xlcode(NIL) to indicate that the character should
be treated as white space or a value consed with @xlcode(NIL) to indicate
that the readmacro should be treated as an occurence of the
specified value. Of course, the readmacro code is free to read
additional characters from the input stream.
XLISP defines several useful read macros@index(read macros):
@begin(itemize)
@xlcode(')@i[<expr>] == @xlcode{(quote} @i[<expr>]@xlcode{)}
@xlcode(#')@i[<expr>] == @xlcode{(function} @i[<expr>]@xlcode{)}
@xlcode{#(}@i[<expr>]...@xlcode{)} == an array of the specified expressions
@xlcode(#x)@i[<hdigits>] == a hexadecimal number (0-9,A-F)
@xlcode(#o)@i[<odigits>] == an octal number (0-7)
@xlcode(#b)@i[<bdigits>] == a binary number (0-1)
@xlcode(#\)@i[<char>] == the ASCII code of the character
@xlcode(#|) ... @xlcode(|#) == a comment
@xlcode(#:)@i[<symbol>] == an uninterned symbol
@xlcode(`)@i[<expr>] == @xlcode{(backquote} @i[<expr>]@xlcode{)}
@xlcode(,)@i[<expr>] == @xlcode{(comma} @i[<expr>]@xlcode{)}
@xlcode(,@@)@i[<expr>] == @xlcode{(comma-at} @i[<expr>]@xlcode{)}
@end(itemize)
@section(Lambda Lists)@index(Lambda Lists)
There are several forms in XLISP that require that a ``lambda
list'' be specified. A lambda list is a definition of the
arguments accepted by a function. There are four different
types of arguments.
The lambda list starts with required arguments. Required
arguments must be specified in every call to the function.
The required arguments are followed by the @xlcode(&optional) arguments.
Optional arguments may be provided or omitted in a call. An
initialization expression may be specified to provide a default
value for an @xlcode(&optional) argument if it is omitted from a call.
If no initialization expression is specified, an omitted
argument is initialized to @xlcode(NIL). It is also possible to provide
the name of a @xlcode(supplied-p) variable that can be used to
determine if a call provided a value for the argument or if the
initialization expression was used. If specified, the supplied-
p variable will be bound to T if a value was specified in the
call and @xlcode(NIL) if the default value was used.
The @xlcode(&optional) arguments are followed by the @xlcode(&rest) argument. The
@xlcode(&rest) argument gets bound to the remainder of the argument list
after the required and @xlcode(&optional) arguments have been removed.
The @xlcode(&rest) argument is followed by the @xlcode(&key) arguments. When a
keyword argument is passed to a function, a pair of values
appears in the argument list. The first expression in the pair
should evaluate to a keyword symbol (a symbol that begins with a
``@code(:)''). The value of the second expression is the value of the
keyword argument. Like @xlcode(&optional) arguments, @xlcode(&key) arguments can
have initialization expressions and supplied-p variables. In
addition, it is possible to specify the keyword to be used in a
function call. If no keyword is specified, the keyword obtained
by adding a ``@code(:)'' to the beginning of the keyword argument symbol
is used. In other words, if the keyword argument symbol is
@xlcode(foo), the keyword will be @xlcode(:foo).
The @xlcode(&key) arguments are followed by the @xlcode(&aux) variables. These
are local variables that are bound during the evaluation of the
function body. It is possible to have initialization
expressions for the @xlcode(&aux) variables.
Here is the complete syntax for lambda lists:
@begin(display)
(@i<rarg>...
[@xlcode(&optional) [@i<oarg> | (@i<oarg> [@i<init> [@i<svar>]])]...]
[@xlcode(&rest) @i<rarg>]
[@xlcode(&key)
[@i<karg> | ([@i<karg> | (@i<key> @i<karg>)] [@i<init> [@i<svar>]])]...
@xlcode(&allow)-other-keys]
[@xlcode(&aux)
[@i<aux> | (@i<aux> [@i<init>])]...])
where:
@i<rarg> is a required argument symbol
@i<oarg> is an @xlcode(&optional) argument symbol
@i<rarg> is the @xlcode(&rest) argument symbol
@i<karg> is a @xlcode(&key) argument symbol
@i<key> is a keyword symbol
@i<aux> is an auxiliary variable symbol
@i<init> is an initialization expression
@i<svar> is a supplied-p variable symbol
@end(display)
@section(Objects)@index(Objects)@label(objects-sec)
Definitions:
@begin(itemize)
selector @itemsep a symbol used to select an appropriate method
message @itemsep a selector and a list of actual arguments
method @itemsep the code that implements a message
@end(itemize)
Since XLISP was created to provide a simple basis for
experimenting with object-oriented programming, one of the
primitive data types included is @i(object). In XLISP, an object
consists of a data structure containing a pointer to the
object's class as well as an array containing the values of the
object's instance variables.
Officially, there is no way to see inside an object (look at the
values of its instance variables). The only way to communicate
with an object is by sending it a message.
You can send a message to an object using the @xlcode(send) function.
This function takes the object as its first argument, the
message selector as its second argument (which must be a symbol)
and the message arguments as its remaining arguments.
The @xlcode(send) function determines the class of the receiving object
and attempts to find a method corresponding to the message
selector in the set of messages defined for that class. If the
message is not found in the object's class and the class has a
super-class, the search continues by looking at the messages
defined for the super-class. This process continues from one
super-class to the next until a method for the message is found.
If no method is found, an error occurs.
@begin(comment)
THIS IS WRONG -- I DON'T KNOW IF IT WAS CORRECT IN THE ORIGINAL XLISP. -RBD
A message can also be sent from the body of a method by using
the current object, but the method lookup starts with the
object's superclass rather than its class. This allows a
subclass to invoke a standard method in its parent class even
though it overrides that method with its own specialized
version.
@end(comment)
When a method is found, the evaluator binds the receiving object
to the symbol @xlcode(self) and evaluates the method using the
remaining elements of the original list as arguments to the
method. These arguments are always evaluated prior to being
bound to their corresponding formal arguments. The result of
evaluating the method becomes the result of the expression.
Within the body of a method, a message can be sent to the current
object by calling the @xlcode[(send self ...)]. The method lookup
starts with the object's class regardless of the class containing
the current method.
Sometimes it is desirable to invoke a general method in a superclass
even when it is overridden by a more specific method in a subclass.
This can be accomplished by calling @xlcode(send-super), which begins
the method lookup in the superclass of the class defining the current
method rather than in the class of the current object.
The @xlcode(send-super) function takes a selector as its first argument
(which must be a symbol) and the message arguments as its remaining
arguments. Notice that @xlcode(send-super) can only be sent from within
a method, and the target of the message is always the current object
(@xlcode(self)). @xlcode[(send-super ...)] is similar to
@xlcode[(send self ...)] except that method lookup begins in the
superclass of the class containing the current method
rather than the class of the current object.
@section(The ``Object'' Class)@index(Object Class)
@xlcode(Object)@index(Object) @itemsep the top of the class hierarchy.
Messages:
@begin(fdescription)
@xlcode(:show@index(:show)) @itemsep show an object's instance variables.
@begin(pdescription)
returns @itemsep the object
@end(pdescription)
@blankspace(1)
@xlcode{:class@index(:class)} @itemsep return the class of an object
@begin(pdescription)
returns @itemsep the class of the object
@end(pdescription)
@blankspace(1)
@xlcode{:isa@index(:isa)} @i(class) @itemsep test if object inherits from class
@begin(pdescription)
returns @itemsep @xlcode(t) if object is an instance of @i(class) or a subclass of @i(class), otherwise @xlcode(nil)
@end(pdescription)
@blankspace(1)
@xlcode(:isnew@index(:isnew)) @itemsep the default object initialization routine
@begin(pdescription)
returns @itemsep the object
@end(pdescription)
@end(fdescription)
@section(The ``Class'' Class)@index(Class class)
@xlcode(Class@index(Class)) @itemsep class of all object classes (including itself)
Messages:
@begin(fdescription)
@xlcode(:new@index(:new)) @itemsep create a new instance of a class
@begin(pdescription)
returns @itemsep the new class object
@end(pdescription)
@blankspace(1)
@xlcode(:isnew@index(:isnew)) @i<ivars> [@i<cvars> [@i<super>]] @itemsep initialize a new class
@begin(pdescription)
@i<ivars> @itemsep the list of instance variable symbols
@i<cvars> @itemsep the list of class variable symbols
@i<super> @itemsep the superclass (default is object)
returns @itemsep the new class object
@end(pdescription)
@blankspace(1)
@xlcode(:answer@index(:answer)) @i<msg> @i<fargs> @i<code> @itemsep add a message to a class
@begin(pdescription)
@i<msg> @itemsep the message symbol
@i<fargs> @itemsep the formal argument list (lambda list)
@i<code> @itemsep a list of executable expressions
returns @itemsep the object
@end(pdescription)
@blankspace(1)
@end(fdescription)
When a new instance of a class is created by sending the message
@xlcode(:new) to an existing class, the message @xlcode(:isnew) followed by
whatever parameters were passed to the @xlcode(:new) message is sent to
the newly created object.
When a new class is created by sending the @xlcode(:new) message to the
object @xlcode(Class), an optional parameter may be specified
indicating the superclass of the new class. If this parameter
is omitted, the new class will be a subclass of @xlcode(Object). A
class inherits all instance variables, class variables, and
methods from its super-class.
@section(Profiling)@index(profiling)
The Xlisp 2.0 release has been extended with a profiling facility, which counts how many times and where @xlcode(eval) is executed. A separate count is maintained for each named function, closure, or macro, and a count indicates an @xlcode(eval) in the immediately (lexically) enclosing named function, closure, or macro. Thus, the count gives an indication of the amount of time spent in a function, not counting nested function calls. The list of all functions executed is maintained on the global @xlcode(*profile*) variable. These functions in turn have @xlcode(*profile*) properties, which maintain the counts. The profile system merely increments counters and puts symbols on the @xlcode(*profile*) list. It is up to the user to initialize data and gather results. Profiling is turned on or off with the @xlcode(profile) function. Unfortunately, methods cannot be profiled with this facility.
@label(symbols-sec)
@section(Symbols)@index(symbols)
@begin(itemize)
@codef(self)@pragma(defn)@index(self) @dash the current object (within a method context)
@codef(*obarray*@pragma(defn)@index(*obarray*)) @dash the object hash table
@codef(*standard-input*@pragma(defn)@index(*standard-input*)) @dash the standard input stream
@codef(*standard-output*@pragma(defn)@index(*standard-output*)) @dash the standard output stream
@codef(*error-output*@pragma(defn)@index(*error-output*)) @dash the error output stream
@codef(*trace-output*@pragma(defn)@index(*trace-output*)) @dash the trace output stream
@codef(*debug-io*@pragma(defn)@index(*debug-io*)) @dash the debug i/o stream
@codef(*breakenable*@pragma(defn)@index(*breakenable*)) @dash flag controlling entering break loop on errors
@codef(*tracelist*@pragma(defn)@index(*tracelist*)) @dash list of names of functions to trace
@codef(*tracenable*@pragma(defn)@index(*tracenable*)) @dash enable trace back printout on errors
@codef(*tracelimit*@pragma(defn)@index(*tracelimit*)) @dash number of levels of trace back information
@codef(*evalhook*@pragma(defn)@index(*evalhook*)) @dash user substitute for the evaluator function
@codef(*applyhook*@pragma(defn)@index(*applyhook*)) @dash (not yet implemented)
@codef(*readtable*@pragma(defn)@index(*readtable*)) @dash the current readtable
@codef(*unbound*@pragma(defn)@index(*unbound*)) @dash indicator for unbound symbols
@codef(*gc-flag*@pragma(defn)@index(*gc-flag*)) @dash controls the printing of gc messages
@codef(*gc-hook*@pragma(defn)@index(*gc-hook*)) @dash function to call after garbage collection
@codef(*integer-format*@pragma(defn)@index(*integer-format*)) @dash format for printing integers (``%d'' or ``%ld'')
@codef(*float-format*@pragma(defn)@index(*float-format*)) @dash format for printing floats (``%g'')
@codef(*print-case*@pragma(defn)@index(*print-case*)) @dash symbol output case (:upcase or :downcase)
@end(itemize)
There are several symbols maintained by the read/eval/print
loop. The symbols @code(+), @code(++), and @code(+++) are bound to the most
recent three input expressions. The symbols @code(*), @code(**) and @code(***)
are bound to the most recent three results. The symbol @code(-) is
bound to the expression currently being evaluated. It becomes
the value of @code(+) at the end of the evaluation.
@section(Evaluation Functions)@index(evaluation functions)
@begin(fdescription)
@begin(fgroup)@xlcode{eval(@i(expr))} @c{[sal]}
@xlcode{(eval@pragma(defn)@index(eval) @t(@i(expr)))} @c{[lisp]} @itemsep evaluate an xlisp expression
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to be evaluated
returns @itemsep the result of evaluating the expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{apply(@i(fun), @i(args))} @c{[sal]}
@xlcode{(apply@pragma(defn)@index(apply) @t(@i(fun)) @t(@i(args)))} @c{[lisp]} @itemsep apply a function to a list of arguments
@end(fgroup)
@begin(pdescription)
@i<fun> @itemsep the function to apply (or function symbol)
@i<args> @itemsep the argument list
returns @itemsep the result of applying the function to the arguments
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{funcall(@i(fun), @i(arg)@r(...))} @c{[sal]}
@xlcode{(funcall@pragma(defn)@index(funcall) @t(@i(fun)) @t(@i(arg))@r(...))} @c{[lisp]} @itemsep call a function with arguments
@end(fgroup)
@begin(pdescription)
@i<fun> @itemsep the function to call (or function symbol)
@i<arg> @itemsep arguments to pass to the function
returns @itemsep the result of calling the function with the arguments
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{quote(@i(expr))} @c{[sal]}
@xlcode{(quote@pragma(defn)@index(quote) @t(@i(expr)))} @c{[lisp]} @itemsep return an expression unevaluated
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to be quoted (quoted)
returns @itemsep @i<expr> unevaluated
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{function(@i(expr))} @c{[sal]}
@xlcode{(function@pragma(defn)@index(function) @t(@i(expr)))} @c{[lisp]} @itemsep get the functional interpretation
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the symbol or lambda expression (quoted)
returns @itemsep the functional interpretation
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{backquote(@i(expr))} @c{[sal]}
@xlcode{(backquote@pragma(defn)@index(backquote) @t(@i(expr)))} @c{[lisp]} @itemsep fill in a template
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the template
returns @itemsep a copy of the template with comma and comma-at
expressions expanded
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{lambda(@i(args), @i(expr)@r(...))} @c{[sal]}
@xlcode{(lambda@pragma(defn)@index(lambda) @t(@i(args)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep make a function closure
@end(fgroup)
@begin(pdescription)
@i<args> @itemsep formal argument list (lambda list) (quoted)
@i<expr> @itemsep expressions of the function body
returns @itemsep the function closure
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{get-lambda-expression(@i(closure))} @c{[sal]}
@xlcode{(get-lambda-expression@pragma(defn)@index(get-lambda-expression) @t(@i(closure)))} @c{[lisp]} @itemsep get the lambda expression
@end(fgroup)
@begin(pdescription)
@i<closure> @itemsep the closure
returns @itemsep the original lambda expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{macroexpand(@i(form))} @c{[sal]}
@xlcode{(macroexpand@pragma(defn)@index(macroexpand) @t(@i(form)))} @c{[lisp]} @itemsep recursively expand macro calls
@end(fgroup)
@begin(pdescription)
@i<form> @itemsep the form to expand
returns @itemsep the macro expansion
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{macroexpand-1(@i(form))} @c{[sal]}
@xlcode{(macroexpand-1@pragma(defn)@index(macroexpand-1) @t(@i(form)))} @c{[lisp]} @itemsep expand a macro call
@end(fgroup)
@begin(pdescription)
@i<form> @itemsep the macro call form
returns @itemsep the macro expansion
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Symbol Functions)@index(Symbol Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{set(@i(sym), @i(expr))} @c{[sal]}
@xlcode{(set@pragma(defn)@index(set) @t(@i(sym)) @t(@i(expr)))} @c{[lisp]} @itemsep set the value of a symbol
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol being set
@i<expr> @itemsep the new value
returns @itemsep the new value
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{setq([@i(sym), @i(expr)]@r(...))} @c{[sal]}
@xlcode{(setq@pragma(defn)@index(setq) [@t(@i(sym)) @t(@i(expr))]@r(...))} @c{[lisp]} @itemsep set the value of a symbol
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol being set (quoted)
@i<expr> @itemsep the new value
returns @itemsep the new value
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{psetq([@i(sym), @i(expr)]@r(...))} @c{[sal]}
@xlcode{(psetq@pragma(defn)@index(psetq) [@t(@i(sym)) @t(@i(expr))]@r(...))} @c{[lisp]} @itemsep parallel version of setq
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol being set (quoted)
@i<expr> @itemsep the new value
returns @itemsep the new value
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{setf([@i(place), @i(expr)]@r(...))} @c{[sal]}
@xlcode{(setf@pragma(defn)@index(setf) [@t(@i(place)) @t(@i(expr))]@r(...))} @c{[lisp]} @itemsep set the value of a field
@end(fgroup)
@begin(pdescription)
@i<place> @itemsep the field specifier (quoted):
@begin(pdescription)
@i<sym> @itemsep set value of a symbol
(car @i<expr>) @itemsep set car of a cons node
(cdr @i<expr>) @itemsep set cdr of a cons node
(nth @i<n> @i<expr>) @itemsep set nth car of a list
(aref @i<expr> @i<n>) @itemsep set nth element of an array
(get @i<sym> @i<prop>) @itemsep set value of a property
(symbol-value @i<sym>) @itemsep set value of a symbol
(symbol-function @i<sym>) @itemsep set functional value of a symbol
(symbol-plist @i<sym>) @itemsep set property list of a symbol
@end(pdescription)@pragma(stopcodef)
@i<expr> @itemsep the new value
returns @itemsep the new value
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@xlcode{(defun@pragma(defn)@index(defun) @t(@i(sym)) @t(@i(fargs)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep define a function
@pragma(startcodef)
@xlcode{(defmacro@pragma(defn)@index(defmacro) @t(@i(sym)) @t(@i(fargs)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep define a macro
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep symbol being defined (quoted)
@i<fargs> @itemsep formal argument list (lambda list) (quoted)
@i<expr> @itemsep expressions constituting the body of the
function (quoted)
returns @itemsep the function symbol
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{gensym([@i(tag)])} @c{[sal]}
@xlcode{(gensym@pragma(defn)@index(gensym) [@t(@i(tag))])} @c{[lisp]} @itemsep generate a symbol
@end(fgroup)
@begin(pdescription)
@i<tag> @itemsep string or number
returns @itemsep the new symbol
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{intern(@i(pname))} @c{[sal]}
@xlcode{(intern@pragma(defn)@index(intern) @t(@i(pname)))} @c{[lisp]} @itemsep make an interned symbol
@end(fgroup)
@begin(pdescription)
@i<pname> @itemsep the symbol's print name string
returns @itemsep the new symbol
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{make-symbol(@i(pname))} @c{[sal]}
@xlcode{(make-symbol@pragma(defn)@index(make-symbol) @t(@i(pname)))} @c{[lisp]} @itemsep make an uninterned symbol
@end(fgroup)
@begin(pdescription)
@i<pname> @itemsep the symbol's print name string
returns @itemsep the new symbol
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{symbol-name(@i(sym))} @c{[sal]}
@xlcode{(symbol-name@pragma(defn)@index(symbol-name) @t(@i(sym)))} @c{[lisp]} @itemsep get the print name of a symbol
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
returns @itemsep the symbol's print name
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{symbol-value(@i(sym))} @c{[sal]}
@xlcode{(symbol-value@pragma(defn)@index(symbol-value) @t(@i(sym)))} @c{[lisp]} @itemsep get the value of a symbol
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
returns @itemsep the symbol's value
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{symbol-function(@i(sym))} @c{[sal]}
@xlcode{(symbol-function@pragma(defn)@index(symbol-function) @t(@i(sym)))} @c{[lisp]} @itemsep get the functional value of a symbol
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
returns @itemsep the symbol's functional value
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{symbol-plist(@i(sym))} @c{[sal]}
@xlcode{(symbol-plist@pragma(defn)@index(symbol-plist) @t(@i(sym)))} @c{[lisp]} @itemsep get the property list of a symbol
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
returns @itemsep the symbol's property list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{hash(@i(sym), @i(n))} @c{[sal]}
@xlcode{(hash@pragma(defn)@index(hash) @t(@i(sym)) @t(@i(n)))} @c{[lisp]} @itemsep compute the hash index for a symbol
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol or string
@i<n> @itemsep the table size (integer)
returns @itemsep the hash index (integer)
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Property List Functions)@index(Property List Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{get(@i(sym), @i(prop))} @c{[sal]}
@xlcode{(get@pragma(defn)@index(get) @t(@i(sym)) @t(@i(prop)))} @c{[lisp]} @itemsep get the value of a property
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
@i<prop> @itemsep the property symbol
returns @itemsep the property value or @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{putprop(@i(sym), @i(val), @i(prop))} @c{[sal]}
@xlcode{(putprop@pragma(defn)@index(putprop) @t(@i(sym)) @t(@i(val)) @t(@i(prop)))} @c{[lisp]} @itemsep put a property onto a property list
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
@i<val> @itemsep the property value
@i<prop> @itemsep the property symbol
returns @itemsep the property value
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{remprop(@i(sym), @i(prop))} @c{[sal]}
@xlcode{(remprop@pragma(defn)@index(remprop) @t(@i(sym)) @t(@i(prop)))} @c{[lisp]} @itemsep remove a property
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
@i<prop> @itemsep the property symbol
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Array Functions)@index(Array Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{aref(@i(array), @i(n))} @c{[sal]}
@xlcode{(aref@pragma(defn)@index(aref) @t(@i(array)) @t(@i(n)))} @c{[lisp]} @itemsep get the nth element of an array
@end(fgroup)
@begin(pdescription)
@i<array> @itemsep the array
@i<n> @itemsep the array index (integer)
returns @itemsep the value of the array element
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{make-array(@i(size))} @c{[sal]}
@xlcode{(make-array@pragma(defn)@index(make-array) @t(@i(size)))} @c{[lisp]} @itemsep make a new array
@end(fgroup)
@begin(pdescription)
@i<size> @itemsep the size of the new array (integer)
returns @itemsep the new array
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{vector(@i(expr)@r(...))} @c{[sal]}
@xlcode{(vector@pragma(defn)@index(vector) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep make an initialized vector
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the vector elements
returns @itemsep the new vector
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(List Functions)@index(List Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{car(@i(expr))} @c{[sal]}
@xlcode{(car@pragma(defn)@index(car) @t(@i(expr)))} @c{[lisp]} @itemsep return the car of a list node
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the list node
returns @itemsep the car of the list node
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{cdr(@i(expr))} @c{[sal]}
@xlcode{(cdr@pragma(defn)@index(cdr) @t(@i(expr)))} @c{[lisp]} @itemsep return the cdr of a list node
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the list node
returns @itemsep the cdr of the list node
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{c@i(xx)r(@i(expr))} @c{[sal]}
@xlcode{(c@i(xx)r@index(cxxr) @t(@i(expr)))} @c{[lisp]} @itemsep all c@i(xx)r combinations
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{c@i(xxx)r(@i(expr))} @c{[sal]}
@xlcode{(c@i(xxx)r@index(cxxxr) @t(@i(expr)))} @c{[lisp]} @itemsep all c@i(xxx)r combinations
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{c@i(xxxx)r(@i(expr))} @c{[sal]}
@xlcode{(c@i(xxxx)r@index(cxxxxr) @t(@i(expr)))} @c{[lisp]} @itemsep all c@i(xxxx)r combinations
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{first(@i(expr))} @c{[sal]}
@xlcode{(first@pragma(defn)@index(first) @t(@i(expr)))} @c{[lisp]} @itemsep a synonym for car
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{second(@i(expr))} @c{[sal]}
@xlcode{(second@pragma(defn)@index(second) @t(@i(expr)))} @c{[lisp]} @itemsep a synonym for cadr
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{third(@i(expr))} @c{[sal]}
@xlcode{(third@pragma(defn)@index(third) @t(@i(expr)))} @c{[lisp]} @itemsep a synonym for caddr
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{fourth(@i(expr))} @c{[sal]}
@xlcode{(fourth@pragma(defn)@index(fourth) @t(@i(expr)))} @c{[lisp]} @itemsep a synonym for cadddr
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{rest(@i(expr))} @c{[sal]}
@xlcode{(rest@pragma(defn)@index(rest) @t(@i(expr)))} @c{[lisp]} @itemsep a synonym for cdr
@end(fgroup)
@begin(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{cons(@i(expr1), @i(expr2))} @c{[sal]}
@xlcode{(cons@pragma(defn)@index(cons) @t(@i(expr1)) @t(@i(expr2)))} @c{[lisp]} @itemsep construct a new list node
@end(fgroup)
@begin(pdescription)
@i<expr1> @itemsep the car of the new list node
@i<expr2> @itemsep the cdr of the new list node
returns @itemsep the new list node
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{list(@i(expr)@r(...))} @c{[sal]}
@xlcode{(list@pragma(defn)@index(list) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep create a list of values
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep expressions to be combined into a list
returns @itemsep the new list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{append(@i(expr)@r(...))} @c{[sal]}
@xlcode{(append@pragma(defn)@index(append) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep append lists
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep lists whose elements are to be appended
returns @itemsep the new list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{reverse(@i(expr))} @c{[sal]}
@xlcode{(reverse@pragma(defn)@index(reverse) @t(@i(expr)))} @c{[lisp]} @itemsep reverse a list
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the list to reverse
returns @itemsep a new list in the reverse order
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{last(@i(list))} @c{[sal]}
@xlcode{(last@pragma(defn)@index(last) @t(@i(list)))} @c{[lisp]} @itemsep return the last list node of a list
@end(fgroup)
@begin(pdescription)
@i<list> @itemsep the list
returns @itemsep the last list node in the list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{member(@i(expr), @i(list), test: @i(test), test-not: @i(test-not))} @c{[sal]}
@xlcode{(member@pragma(defn)@index(member) @t(@i(expr)) @t(@i(list)) @t(&key )@t(:test) @t(:test-not))} @c{[lisp]} @itemsep find an expression in a list
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to find
@i<list> @itemsep the list to search
:test @itemsep the test function (defaults to eql)
:test-not @itemsep the test function (sense inverted)
returns @itemsep the remainder of the list starting with the expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{assoc(@i(expr), @i(alist), test: @i(test), test-not: @i(test-not))} @c{[sal]}
@xlcode{(assoc@pragma(defn)@index(assoc) @t(@i(expr)) @t(@i(alist)) @t(&key )@t(:test) @t(:test-not))} @c{[lisp]} @itemsep find an expression in an a-list
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to find
@i<alist> @itemsep the association list
:test @itemsep the test function (defaults to eql)
:test-not @itemsep the test function (sense inverted)
returns @itemsep the alist entry or @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{remove(@i(expr), @i(list), test: @i(test), test-not: @i(test-not))} @c{[sal]}
@xlcode{(remove@pragma(defn)@index(remove) @t(@i(expr)) @t(@i(list)) @t(&key )@t(:test) @t(:test-not))} @c{[lisp]} @itemsep remove elements from a list
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the element to remove
@i<list> @itemsep the list
:test @itemsep the test function (defaults to eql)
:test-not @itemsep the test function (sense inverted)
returns @itemsep copy of list with matching expressions removed
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{remove-if(@i(test), @i(list))} @c{[sal]}
@xlcode{(remove-if@pragma(defn)@index(remove-if) @t(@i(test)) @t(@i(list)))} @c{[lisp]} @itemsep remove elements that pass test
@end(fgroup)
@begin(pdescription)
@i<test> @itemsep the test predicate
@i<list> @itemsep the list
returns @itemsep copy of list with matching elements removed
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{remove-if-not(@i(test), @i(list))} @c{[sal]}
@xlcode{(remove-if-not@pragma(defn)@index(remove-if-not) @t(@i(test)) @t(@i(list)))} @c{[lisp]} @itemsep remove elements that fail test
@end(fgroup)
@begin(pdescription)
@i<test> @itemsep the test predicate
@i<list> @itemsep the list
returns @itemsep copy of list with non-matching elements removed
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{length(@i(expr))} @c{[sal]}
@xlcode{(length@pragma(defn)@index(length) @t(@i(expr)))} @c{[lisp]} @itemsep find the length of a list, vector or string
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the list, vector or string
returns @itemsep the length of the list, vector or string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{nth(@i(n), @i(list))} @c{[sal]}
@xlcode{(nth@pragma(defn)@index(nth) @t(@i(n)) @t(@i(list)))} @c{[lisp]} @itemsep return the nth element of a list
@end(fgroup)
@begin(pdescription)
@i<n> @itemsep the number of the element to return (zero origin)
@i<list> @itemsep the list
returns @itemsep the nth element or @xlcode(nil) if the list isn't that long
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{nthcdr(@i(n), @i(list))} @c{[sal]}
@xlcode{(nthcdr@pragma(defn)@index(nthcdr) @t(@i(n)) @t(@i(list)))} @c{[lisp]} @itemsep return the nth cdr of a list
@end(fgroup)
@begin(pdescription)
@i<n> @itemsep the number of the element to return (zero origin)
@i<list> @itemsep the list
returns @itemsep the nth cdr or @xlcode(nil) if the list isn't that long
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{mapc(@i(fcn), @i(list1), @i(list)@r(...))} @c{[sal]}
@xlcode{(mapc@pragma(defn)@index(mapc) @t(@i(fcn)) @t(@i(list1)) @t(@i(list))@r(...))} @c{[lisp]} @itemsep apply function to successive cars
@end(fgroup)
@begin(pdescription)
@i<fcn> @itemsep the function or function name
@i<listn> @itemsep a list for each argument of the function
returns @itemsep the first list of arguments
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{mapcar(@i(fcn), @i(list1), @i(list)@r(...))} @c{[sal]}
@xlcode{(mapcar@pragma(defn)@index(mapcar) @t(@i(fcn)) @t(@i(list1)) @t(@i(list))@r(...))} @c{[lisp]} @itemsep apply function to successive cars
@end(fgroup)
@begin(pdescription)
@i<fcn> @itemsep the function or function name
@i<listn> @itemsep a list for each argument of the function
returns @itemsep a list of the values returned
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{mapl(@i(fcn), @i(list1), @i(list)@r(...))} @c{[sal]}
@xlcode{(mapl@pragma(defn)@index(mapl) @t(@i(fcn)) @t(@i(list1)) @t(@i(list))@r(...))} @c{[lisp]} @itemsep apply function to successive cdrs
@end(fgroup)
@begin(pdescription)
@i<fcn> @itemsep the function or function name
@i<listn> @itemsep a list for each argument of the function
returns @itemsep the first list of arguments
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{maplist(@i(fcn), @i(list1), @i(list)@r(...))} @c{[sal]}
@xlcode{(maplist@pragma(defn)@index(maplist) @t(@i(fcn)) @t(@i(list1)) @t(@i(list))@r(...))} @c{[lisp]} @itemsep apply function to successive cdrs
@end(fgroup)
@begin(pdescription)
@i<fcn> @itemsep the function or function name
@i<listn> @itemsep a list for each argument of the function
returns @itemsep a list of the values returned
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{subst(@i(to), @i(from), @i(expr), test: @i(test), test-not: @i(test-not))} @c{[sal]}
@xlcode{(subst@pragma(defn)@index(subst) @t(@i(to)) @t(@i(from)) @t(@i(expr)) @t(&key )@t(:test) @t(:test-not))} @c{[lisp]} @itemsep substitute expressions
@end(fgroup)
@begin(pdescription)
@i<to> @itemsep the new expression
@i<from> @itemsep the old expression
@i<expr> @itemsep the expression in which to do the substitutions
:test @itemsep the test function (defaults to eql)
:test-not @itemsep the test function (sense inverted)
returns @itemsep the expression with substitutions
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{sublis(@i(alist), @i(expr), test: @i(test), test-not: @i(test-not))} @c{[sal]}
@xlcode{(sublis@pragma(defn)@index(sublis) @t(@i(alist)) @t(@i(expr)) @t(&key )@t(:test) @t(:test-not))} @c{[lisp]} @itemsep substitute with an a-list
@end(fgroup)
@begin(pdescription)
@i<alist> @itemsep the association list
@i<expr> @itemsep the expression in which to do the substitutions
:test @itemsep the test function (defaults to eql)
:test-not @itemsep the test function (sense inverted)
returns @itemsep the expression with substitutions
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Destructive List Functions)@index(Destructive List Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{rplaca(@i(list), @i(expr))} @c{[sal]}
@xlcode{(rplaca@pragma(defn)@index(rplaca) @t(@i(list)) @t(@i(expr)))} @c{[lisp]} @itemsep replace the car of a list node
@end(fgroup)
@begin(pdescription)
@i<list> @itemsep the list node
@i<expr> @itemsep the new value for the car of the list node
returns @itemsep the list node after updating the car
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{rplacd(@i(list), @i(expr))} @c{[sal]}
@xlcode{(rplacd@pragma(defn)@index(rplacd) @t(@i(list)) @t(@i(expr)))} @c{[lisp]} @itemsep replace the cdr of a list node
@end(fgroup)
@begin(pdescription)
@i<list> @itemsep the list node
@i<expr> @itemsep the new value for the cdr of the list node
returns @itemsep the list node after updating the cdr
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{nconc(@i(list)@r(...))} @c{[sal]}
@xlcode{(nconc@pragma(defn)@index(nconc) @t(@i(list))@r(...))} @c{[lisp]} @itemsep destructively concatenate lists
@end(fgroup)
@begin(pdescription)
@i<list> @itemsep lists to concatenate
returns @itemsep the result of concatenating the lists
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{delete(@i(expr), test: @i(test), test-not: @i(test-not))} @c{[sal]}
@xlcode{(delete@pragma(defn)@index(delete) @t(@i(expr)) @t(&key )@t(:test) @t(:test-not))} @c{[lisp]} @itemsep delete elements from a list
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the element to delete
@i<list> @itemsep the list
:test @itemsep the test function (defaults to eql)
:test-not @itemsep the test function (sense inverted)
returns @itemsep the list with the matching expressions deleted
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{delete-if(@i(test), @i(list))} @c{[sal]}
@xlcode{(delete-if@pragma(defn)@index(delete-if) @t(@i(test)) @t(@i(list)))} @c{[lisp]} @itemsep delete elements that pass test
@end(fgroup)
@begin(pdescription)
@i<test> @itemsep the test predicate
@i<list> @itemsep the list
returns @itemsep the list with matching elements deleted
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{delete-if-not(@i(test), @i(list))} @c{[sal]}
@xlcode{(delete-if-not@pragma(defn)@index(delete-if-not) @t(@i(test)) @t(@i(list)))} @c{[lisp]} @itemsep delete elements that fail test
@end(fgroup)
@begin(pdescription)
@i<test> @itemsep the test predicate
@i<list> @itemsep the list
returns @itemsep the list with non-matching elements deleted
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{sort(@i(list), @i(test))} @c{[sal]}
@xlcode{(sort@pragma(defn)@index(sort) @t(@i(list)) @t(@i(test)))} @c{[lisp]} @itemsep sort a list
@end(fgroup)
@begin(pdescription)
@i<list> @itemsep the list to sort
@i<test> @itemsep the comparison function
returns @itemsep the sorted list
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Predicate Functions)@index(Predicate Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{atom(@i(expr))} @c{[sal]}
@xlcode{(atom@pragma(defn)@index(atom) @t(@i(expr)))} @c{[lisp]} @itemsep is this an atom?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is an atom, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{symbolp(@i(expr))} @c{[sal]}
@xlcode{(symbolp@pragma(defn)@index(symbolp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a symbol?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the expression is a symbol, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{numberp(@i(expr))} @c{[sal]}
@xlcode{(numberp@pragma(defn)@index(numberp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a number?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the expression is a number, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{null(@i(expr))} @c{[sal]}
@xlcode{(null@pragma(defn)@index(null) @t(@i(expr)))} @c{[lisp]} @itemsep is this an empty list?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the list to check
returns @itemsep @xlcode(t) if the list is empty, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{not(@i(expr))} @c{[sal]}
@xlcode{(not@pragma(defn)@index(not) @t(@i(expr)))} @c{[lisp]} @itemsep is this false?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
return @itemsep @xlcode(t) if the value is @xlcode(nil), @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{listp(@i(expr))} @c{[sal]}
@xlcode{(listp@pragma(defn)@index(listp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a list?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is a cons or @xlcode(nil), @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{endp(@i(list))} @c{[sal]}
@xlcode{(endp@pragma(defn)@index(endp) @t(@i(list)))} @c{[lisp]} @itemsep is this the end of a list
@end(fgroup)
@begin(pdescription)
@i<list> @itemsep the list
returns @itemsep @xlcode(t) if the value is @xlcode(nil), @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{consp(@i(expr))} @c{[sal]}
@xlcode{(consp@pragma(defn)@index(consp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a non-empty list?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is a cons, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{integerp(@i(expr))} @c{[sal]}
@xlcode{(integerp@pragma(defn)@index(integerp) @t(@i(expr)))} @c{[lisp]} @itemsep is this an integer?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is an integer, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{floatp(@i(expr))} @c{[sal]}
@xlcode{(floatp@pragma(defn)@index(floatp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a float?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is a float, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{stringp(@i(expr))} @c{[sal]}
@xlcode{(stringp@pragma(defn)@index(stringp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a string?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is a string, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{characterp(@i(expr))} @c{[sal]}
@xlcode{(characterp@pragma(defn)@index(characterp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a character?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is a character, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{arrayp(@i(expr))} @c{[sal]}
@xlcode{(arrayp@pragma(defn)@index(arrayp) @t(@i(expr)))} @c{[lisp]} @itemsep is this an array?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is an array, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{streamp(@i(expr))} @c{[sal]}
@xlcode{(streamp@pragma(defn)@index(streamp) @t(@i(expr)))} @c{[lisp]} @itemsep is this a stream?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is a stream, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{objectp(@i(expr))} @c{[sal]}
@xlcode{(objectp@pragma(defn)@index(objectp) @t(@i(expr)))} @c{[lisp]} @itemsep is this an object?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is an object, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{filep(@i(expr))} @c{[sal]}
@xlcode{(filep@pragma(defn)@index(filep) @t(@i(expr)))} @c{[lisp]}@foot(This is not part of standard XLISP nor is it built-in. Nyquist defines it though.) @itemsep is this a file?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to check
returns @itemsep @xlcode(t) if the value is an object, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{boundp(@i(sym))} @c{[sal]}
@xlcode{(boundp@pragma(defn)@index(boundp) @t(@i(sym)))} @c{[lisp]} @itemsep is a value bound to this symbol?
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
returns @itemsep @xlcode(t) if a value is bound to the symbol, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{fboundp(@i(sym))} @c{[sal]}
@xlcode{(fboundp@pragma(defn)@index(fboundp) @t(@i(sym)))} @c{[lisp]} @itemsep is a functional value bound to this symbol?
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the symbol
returns @itemsep @xlcode(t) if a functional value is bound to the symbol,
@xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{minusp(@i(expr))} @c{[sal]}
@xlcode{(minusp@pragma(defn)@index(minusp) @t(@i(expr)))} @c{[lisp]} @itemsep is this number negative?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the number to test
returns @itemsep @xlcode(t) if the number is negative, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{zerop(@i(expr))} @c{[sal]}
@xlcode{(zerop@pragma(defn)@index(zerop) @t(@i(expr)))} @c{[lisp]} @itemsep is this number zero?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the number to test
returns @itemsep @xlcode(t) if the number is zero, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{plusp(@i(expr))} @c{[sal]}
@xlcode{(plusp@pragma(defn)@index(plusp) @t(@i(expr)))} @c{[lisp]} @itemsep is this number positive?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the number to test
returns @itemsep @xlcode(t) if the number is positive, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{evenp(@i(expr))} @c{[sal]}
@xlcode{(evenp@pragma(defn)@index(evenp) @t(@i(expr)))} @c{[lisp]} @itemsep is this integer even?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the integer to test
returns @itemsep @xlcode(t) if the integer is even, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{oddp(@i(expr))} @c{[sal]}
@xlcode{(oddp@pragma(defn)@index(oddp) @t(@i(expr)))} @c{[lisp]} @itemsep is this integer odd?
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the integer to test
returns @itemsep @xlcode(t) if the integer is odd, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{eq(@i(expr1), @i(expr2))} @c{[sal]}
@xlcode{(eq@pragma(defn)@index(eq) @t(@i(expr1)) @t(@i(expr2)))} @c{[lisp]} @itemsep are the expressions identical?
@end(fgroup)
@begin(pdescription)
@i<expr1> @itemsep the first expression
@i<expr2> @itemsep the second expression
returns @itemsep @xlcode(t) if they are equal, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{eql(@i(expr1), @i(expr2))} @c{[sal]}
@xlcode{(eql@pragma(defn)@index(eql) @t(@i(expr1)) @t(@i(expr2)))} @c{[lisp]} @itemsep are the expressions identical? (works with all numbers)
@end(fgroup)
@begin(pdescription)
@i<expr1> @itemsep the first expression
@i<expr2> @itemsep the second expression
returns @itemsep @xlcode(t) if they are equal, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{equal(@i(expr1), @i(expr2))} @c{[sal]}
@xlcode{(equal@pragma(defn)@index(equal) @t(@i(expr1)) @t(@i(expr2)))} @c{[lisp]} @itemsep are the expressions equal?
@end(fgroup)
@begin(pdescription)
@i<expr1> @itemsep the first expression
@i<expr2> @itemsep the second expression
returns @itemsep @xlcode(t) if they are equal, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Control Constructs)@index(Control Constructs)
@begin(fdescription)
@xlcode{(cond@pragma(defn)@index(cond) @t(@i(pair))@r(...))} @c{[lisp]} @itemsep evaluate conditionally
@begin(pdescription)
@i<pair> @itemsep pair consisting of:
@begin(pdescription)
(@i<pred> @i<expr>...)
@end(pdescription)@pragma(stopcodef)
where:
@begin(pdescription)
@i<pred> @itemsep is a predicate expression
@i<expr> @itemsep evaluated if the predicate
is not @xlcode(nil)
@end(pdescription)@pragma(stopcodef)
returns @itemsep the value of the first expression whose predicate is not
@xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{and(@i(expr)@r(...))} @c{[sal]}
@xlcode{(and@pragma(defn)@index(and) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the logical and of a list of expressions
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expressions to be anded
returns @itemsep @xlcode(nil) if any expression evaluates to @xlcode(nil),
otherwise the value of the last expression
(evaluation of expressions stops after the first
expression that evaluates to @xlcode(nil))
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{or(@i(expr)@r(...))} @c{[sal]}
@xlcode{(or@pragma(defn)@index(or) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the logical or of a list of expressions
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expressions to be ored
returns @itemsep @xlcode(nil) if all expressions evaluate to @xlcode(nil),
otherwise the value of the first non-@xlcode(nil) expression
(evaluation of expressions stops after the first
expression that does not evaluate to @xlcode(nil))
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{if(@i(texpr), @i(expr1)[, @i(expr2)])} @c{[sal]}
@xlcode{(if@pragma(defn)@index(if) @t(@i(texpr)) @t(@i(expr1)) [@t(@i(expr2))])} @c{[lisp]} @itemsep evaluate expressions conditionally
@end(fgroup)
@begin(pdescription)
@i<texpr> @itemsep the test expression
@i<expr1> @itemsep the expression to be evaluated if texpr is non-@xlcode(nil)
@i<expr2> @itemsep the expression to be evaluated if texpr is @xlcode(nil)
returns @itemsep the value of the selected expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{when(@i(texpr), @i(expr)@r(...))} @c{[sal]}
@xlcode{(when@pragma(defn)@index(when) @t(@i(texpr)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep evaluate only when a condition is true
@end(fgroup)
@begin(pdescription)
@i<texpr> @itemsep the test expression
@i<expr> @itemsep the expression(s) to be evaluated if texpr is non-@xlcode(nil)
returns @itemsep the value of the last expression or @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{unless(@i(texpr), @i(expr)@r(...))} @c{[sal]}
@xlcode{(unless@pragma(defn)@index(unless) @t(@i(texpr)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep evaluate only when a condition is false
@end(fgroup)
@begin(pdescription)
@i<texpr> @itemsep the test expression
@i<expr> @itemsep the expression(s) to be evaluated if texpr is @xlcode(nil)
returns @itemsep the value of the last expression or @xlcode(nil)
@end(pdescription)
@blankspace(1)
@xlcode{(case@pragma(defn)@index(case) @t(@i(expr)) @t(@i(case))@r(...))} @c{[lisp]} @itemsep select by case
@begin(pdescription)
@i<expr> @itemsep the selection expression
@i<case> @itemsep pair consisting of:
@begin(pdescription)
(@i<value> @i<expr>...)
@end(pdescription)@pragma(stopcodef)
where:
@begin(pdescription)
@i<value> @itemsep is a single expression or a list of
expressions (unevaluated)
@i<expr> @itemsep are expressions to execute if the
case matches
@end(pdescription)@pragma(stopcodef)
returns @itemsep the value of the last expression of the matching case
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@xlcode{(let@pragma(defn)@index(let) (@t(@i(binding))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep create local bindings
@pragma(startcodef)
@xlcode{(let*@pragma(defn)@index(let*) (@t(@i(binding))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep let with sequential binding
@end(fgroup)
@begin(pdescription)
@i<binding> @itemsep the variable bindings each of which is either:
@begin(pdescription)
1) a symbol (which is initialized to @xlcode(nil))
2) a list whose car is a symbol and whose cadr
is an initialization expression
@end(pdescription)@pragma(stopcodef)
@i<expr> @itemsep the expressions to be evaluated
returns @itemsep the value of the last expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@xlcode{(flet@pragma(defn)@index(flet) (@t(@i(binding))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep create local functions
@pragma(startcodef)
@xlcode{(labels@pragma(defn)@index(labels) (@t(@i(binding))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep flet with recursive functions
@pragma(startcodef)
@xlcode{(macrolet@pragma(defn)@index(macrolet) (@t(@i(binding))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep create local macros
@end(fgroup)
@begin(pdescription)
@i<binding> @itemsep the function bindings each of which is:
@begin(pdescription)
(@i<sym> @i<fargs> @i<expr>...)
@end(pdescription)@pragma(stopcodef)
where:
@begin(pdescription)
@i<sym> @itemsep the function/macro name
@i<fargs> @itemsep formal argument list (lambda list)
@i<expr> @itemsep expressions constituting the body of
the function/macro
@end(pdescription)@pragma(stopcodef)
@i<expr> @itemsep the expressions to be evaluated
returns @itemsep the value of the last expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{catch(@i(sym), @i(expr)@r(...))} @c{[sal]}
@xlcode{(catch@pragma(defn)@index(catch) @t(@i(sym)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep evaluate expressions and catch throws
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the catch tag
@i<expr> @itemsep expressions to evaluate
returns @itemsep the value of the last expression the throw expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{throw(@i(sym)[, @i(expr)])} @c{[sal]}
@xlcode{(throw@pragma(defn)@index(throw) @t(@i(sym)) [@t(@i(expr))])} @c{[lisp]} @itemsep throw to a catch
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the catch tag
@i<expr> @itemsep the value for the catch to return (defaults to @xlcode(nil))
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{unwind-protect(@i(expr), @i(cexpr)@r(...))} @c{[sal]}
@xlcode{(unwind-protect@pragma(defn)@index(unwind-protect) @t(@i(expr)) @t(@i(cexpr))@r(...))} @c{[lisp]} @itemsep protect evaluation of an expression
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to protect
@i<cexpr> @itemsep the cleanup expressions
returns @itemsep the value of the expression@*
Note: unwind-protect guarantees to execute the cleanup expressions
even if a non-local exit terminates the evaluation of the
protected expression
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Looping Constructs)@index(Looping Constructs)
@begin(fdescription)
@xlcode{(loop@pragma(defn)@index(loop) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep basic looping form
@begin(pdescription)
@i<expr> @itemsep the body of the loop
returns @itemsep never returns (must use non-local exit)
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@xlcode{(do@pragma(defn)@index(do) (@t(@i(binding))@r(...)) (@t(@i(texpr)) @t(@i(rexpr))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]}
@pragma(endcodef)
@xlcode{(do*@pragma(defn)@index(do*) (@t(@i(binding))@r(...)) (@t(@i(texpr)) @t(@i(rexpr))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]}
@end(fgroup)
@begin(pdescription)
@i<binding> @itemsep the variable bindings each of which is either:
@begin(pdescription)
1) a symbol (which is initialized to @xlcode(nil))
2) a list of the form: (@i<sym> @i<init> [@i<step>])
where:
@begin(pdescription)
@i<sym> @itemsep is the symbol to bind
@i<init> @itemsep is the initial value of the symbol
@i<step> @itemsep is a step expression
@end(pdescription)
@end(pdescription)@pragma(stopcodef)
@i<texpr> @itemsep the termination test expression
@i<rexpr> @itemsep result expressions (the default is @xlcode(nil))
@i<expr> @itemsep the body of the loop (treated like an implicit prog)
returns @itemsep the value of the last result expression
@end(pdescription)
@blankspace(1)
@xlcode{(dolist@pragma(defn)@index(dolist) (@t(@i(sym)) @t(@i(expr)) [@t(@i(rexpr))]) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep loop through a list
@begin(pdescription)
@i<sym> @itemsep the symbol to bind to each list element
@i<expr> @itemsep the list expression
@i<rexpr> @itemsep the result expression (the default is @xlcode(nil))
@i<expr> @itemsep the body of the loop (treated like an implicit prog)
@end(pdescription)
@blankspace(1)
@xlcode{(dotimes@pragma(defn)@index(dotimes) (@t(@i(sym)) @t(@i(expr)) [@t(@i(rexpr))]) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep loop from zero to n-1
@begin(pdescription)
@i<sym> @itemsep the symbol to bind to each value from 0 to n-1
@i<expr> @itemsep the number of times to loop
@i<rexpr> @itemsep the result expression (the default is @xlcode(nil))
@i<expr> @itemsep the body of the loop (treated like an implicit prog)
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(The Program Feature)@index(The Program Feature)
@begin(fdescription)
@begin(fgroup)
@xlcode{(prog@pragma(defn)@index(prog) (@t(@i(binding))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the program feature
@pragma(startcodef)
@xlcode{(prog*@pragma(defn)@index(prog*) (@t(@i(binding))@r(...)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep prog with sequential binding
@end(fgroup)
@begin(pdescription)
@i<binding> @itemsep the variable bindings each of which is either:
@begin(pdescription)
1) a symbol (which is initialized to @xlcode(nil))
2) a list whose car is a symbol and whose cadr
is an initialization expression
@end(pdescription)@pragma(stopcodef)
@i<expr> @itemsep expressions to evaluate or tags (symbols)
returns @itemsep @xlcode(nil) or the argument passed to the return function
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{block(@i(name), @i(expr)@r(...))} @c{[sal]}
@xlcode{(block@pragma(defn)@index(block) @t(@i(name)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep named block
@end(fgroup)
@begin(pdescription)
@i<name> @itemsep the block name (symbol)
@i<expr> @itemsep the block body
returns @itemsep the value of the last expression
@end(pdescription)
@blankspace(1)
@xlcode{(return@pragma(defn)@index(return) [@t(@i(expr))])} @c{[lisp]} @itemsep cause a prog construct to return a value
@begin(pdescription)
@i<expr> @itemsep the value (defaults to @xlcode(nil))
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{return-from(@i(name)[, @i(value)])} @c{[sal]}
@xlcode{(return-from@pragma(defn)@index(return-from) @t(@i(name)) [@t(@i(value))])} @c{[lisp]} @itemsep return from a named block
@end(fgroup)
@begin(pdescription)
@i<name> @itemsep the block name (symbol)
@i<value> @itemsep the value to return (defaults to @xlcode(nil))
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{tagbody(@i(expr)@r(...))} @c{[sal]}
@xlcode{(tagbody@pragma(defn)@index(tagbody) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep block with labels
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep expression(s) to evaluate or tags (symbols)
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{go(@i(sym))} @c{[sal]}
@xlcode{(go@pragma(defn)@index(go) @t(@i(sym)))} @c{[lisp]} @itemsep go to a tag within a tagbody or prog
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the tag (quoted)
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@xlcode{(progv@pragma(defn)@index(progv) @t(@i(slist)) @t(@i(vlist)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep dynamically bind symbols
@begin(pdescription)
@i<slist> @itemsep list of symbols
@i<vlist> @itemsep list of values to bind to the symbols
@i<expr> @itemsep expression(s) to evaluate
returns @itemsep the value of the last expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{prog1(@i(expr1), @i(expr)@r(...))} @c{[sal]}
@xlcode{(prog1@pragma(defn)@index(prog1) @t(@i(expr1)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep execute expressions sequentially
@end(fgroup)
@begin(pdescription)
@i<expr1> @itemsep the first expression to evaluate
@i<expr> @itemsep the remaining expressions to evaluate
returns @itemsep the value of the first expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{prog2(@i(expr1), @i(expr2), @i(expr)@r(...))} @c{[sal]}
@xlcode{(prog2@pragma(defn)@index(prog2) @t(@i(expr1)) @t(@i(expr2)) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep execute expressions sequentially
@end(fgroup)
@begin(pdescription)
@i<expr1> @itemsep the first expression to evaluate
@i<expr2> @itemsep the second expression to evaluate
@i<expr> @itemsep the remaining expressions to evaluate
returns @itemsep the value of the second expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{progn(@i(expr)@r(...))} @c{[sal]}
@xlcode{(progn@pragma(defn)@index(progn) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep execute expressions sequentially
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expressions to evaluate
returns @itemsep the value of the last expression (or @xlcode(nil))
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Debugging and Error Handling)@index(Debugging)@index(Error Handling)
@begin(fdescription)
@begin(fgroup)@xlcode{trace(@i(sym))} @c{[sal]}
@xlcode{(trace@pragma(defn)@index(trace) @t(@i(sym)))} @c{[lisp]} @itemsep add a function to the trace list
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the function to add (quoted)
returns @itemsep the trace list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{untrace(@i(sym))} @c{[sal]}
@xlcode{(untrace@pragma(defn)@index(untrace) @t(@i(sym)))} @c{[lisp]} @itemsep remove a function from the trace list
@end(fgroup)
@begin(pdescription)
@i<sym> @itemsep the function to remove (quoted)
returns @itemsep the trace list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{error(@i(emsg)[, @i(arg)])} @c{[sal]}
@xlcode{(error@pragma(defn)@index(error) @t(@i(emsg)) [@t(@i(arg))])} @c{[lisp]} @itemsep signal a non-correctable error
@end(fgroup)
@begin(pdescription)
@i<emsg> @itemsep the error message string
@i<arg> @itemsep the argument expression (printed after the message)
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{cerror(@i(cmsg), @i(emsg)[, @i(arg)])} @c{[sal]}
@xlcode{(cerror@pragma(defn)@index(cerror) @t(@i(cmsg)) @t(@i(emsg)) [@t(@i(arg))])} @c{[lisp]} @itemsep signal a correctable error
@end(fgroup)
@begin(pdescription)
@i<cmsg> @itemsep the continue message string
@i<emsg> @itemsep the error message string
@i<arg> @itemsep the argument expression (printed after the message)
returns @itemsep @xlcode(nil) when continued from the break loop
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{break([@i(bmsg)[, @i(arg)]])} @c{[sal]}
@xlcode{(break@pragma(defn)@index(break) [@t(@i(bmsg)) [@t(@i(arg))]])} @c{[lisp]} @itemsep enter a break loop
@end(fgroup)
@begin(pdescription)
@i<bmsg> @itemsep the break message string (defaults to @xlcode(**break**))
@i<arg> @itemsep the argument expression (printed after the message)
returns @itemsep @xlcode(nil) when continued from the break loop
@end(pdescription)
@blankspace(1)
@xlcode{(clean-up@pragma(defn)@index(clean-up))} @c{[lisp]} @itemsep clean-up after an error
@begin(pdescription)
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@xlcode{(top-level@pragma(defn)@index(top-level))} @c{[lisp]} @itemsep clean-up after an error and return to the top level
@begin(pdescription)
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@xlcode{(continue@pragma(defn)@index(continue))} @c{[lisp]} @itemsep continue from a correctable error
@begin(pdescription)
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@xlcode{(errset@pragma(defn)@index(errset) @t(@i(expr)) [@t(@i(pflag))])} @c{[lisp]} @itemsep trap errors
@begin(pdescription)
@i<expr> @itemsep the expression to execute
@i<pflag> @itemsep flag to control printing of the error message
returns @itemsep the value of the last expression consed with @xlcode(nil)
or @xlcode(nil) on error
@end(pdescription)
@blankspace(1)
@xlcode{(baktrace@pragma(defn)@index(baktrace)@index(debugging)@index(stack trace) [@t(@i(n))])} @c{[lisp]} @itemsep print n levels of trace back information
@begin(pdescription)
@i<n> @itemsep the number of levels (defaults to all levels)
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@xlcode{(evalhook@pragma(defn)@index(evalhook) @t(@i(expr)) @t(@i(ehook)) @t(@i(ahook)) [@t(@i(env))])} @c{[lisp]} @itemsep evaluate with hooks
@begin(pdescription)
@i<expr> @itemsep the expression to evaluate
@i<ehook> @itemsep the value for @xlcode(*evalhook*)
@i<ahook> @itemsep the value for @xlcode(*applyhook*)
@i<env> @itemsep the environment (default is @xlcode(nil))
returns @itemsep the result of evaluating the expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{profile(@i(flag))} @c{[sal]}
@xlcode{(profile@pragma(defn)@index(profile) @t(@i(flag)))} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep turn profiling on or off.
@end(fgroup)
@begin(pdescription)
@i<flag> @itemsep @xlcode(nil) turns profiling off, otherwise on
returns @itemsep the previous state of profiling.
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Arithmetic Functions)@index(Arithmetic Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{truncate(@i(expr))} @c{[sal]}
@xlcode{(truncate@pragma(defn)@index(truncate) @t(@i(expr)))} @c{[lisp]} @itemsep truncates a floating point number to an integer
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the number
returns @itemsep the result of truncating the number
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{float(@i(expr))} @c{[sal]}
@xlcode{(float@pragma(defn)@index(float) @t(@i(expr)))} @c{[lisp]} @itemsep converts an integer to a floating point number
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the number
returns @itemsep the result of floating the integer
@end(pdescription)
@blankspace(1)
@xlcode{(+@pragma(defn)@index(+) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep add a list of numbers
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the addition
@end(pdescription)
@blankspace(1)
@xlcode{(-@pragma(defn)@index(-) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep subtract a list of numbers or negate a single number
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the subtraction
@end(pdescription)
@blankspace(1)
@xlcode{(*@pragma(defn)@index(*) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep multiply a list of numbers
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the multiplication
@end(pdescription)
@blankspace(1)
@xlcode{(/@pragma(defn)@index(/) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep divide a list of numbers
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the division
@end(pdescription)
@blankspace(1)
@xlcode{(1+@pragma(defn)@index(1+) @t(@i(expr)))} @c{[lisp]} @itemsep add one to a number
@begin(pdescription)
@i<expr> @itemsep the number
returns @itemsep the number plus one
@end(pdescription)
@blankspace(1)
@xlcode{(1-@pragma(defn)@index(1-) @t(@i(expr)))} @c{[lisp]} @itemsep subtract one from a number
@begin(pdescription)
@i<expr> @itemsep the number
returns @itemsep the number minus one
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{rem(@i(expr)@r(...))} @c{[sal]}
@xlcode{(rem@pragma(defn)@index(rem)@index(remainder)@index(modulo (rem) function) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep remainder of a list of numbers
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the remainder operation
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{min(@i(expr)@r(...))} @c{[sal]}
@xlcode{(min@pragma(defn)@index(min)@index(minimum) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the smallest of a list of numbers
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expressions to be checked
returns @itemsep the smallest number in the list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{max(@i(expr)@r(...))} @c{[sal]}
@xlcode{(max@pragma(defn)@index(max)@index(maximum) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the largest of a list of numbers
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expressions to be checked
returns @itemsep the largest number in the list
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{abs(@i(expr))} @c{[sal]}
@xlcode{(abs@pragma(defn)@index(abs) @t(@i(expr)))} @c{[lisp]} @itemsep the absolute value of a number
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the number
returns @itemsep the absolute value of the number
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{gcd(@i(n1), @i(n2)@r(...))} @c{[sal]}
@xlcode{(gcd@pragma(defn)@index(gcd) @t(@i(n1)) @t(@i(n2))@r(...))} @c{[lisp]} @itemsep compute the greatest common divisor
@end(fgroup)
@begin(pdescription)
@i<n1> @itemsep the first number (integer)
@i<n2> @itemsep the second number(s) (integer)
returns @itemsep the greatest common divisor
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{random(@i(n))} @c{[sal]}
@xlcode{(random@pragma(defn)@index(random) @t(@i(n)))} @c{[lisp]} @itemsep compute a random number between 0 and n-1 inclusive
@end(fgroup)
@begin(pdescription)
@i<n> @itemsep the upper bound (integer)
returns @itemsep a random number
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{rrandom()} @c{[sal]}
@xlcode{(rrandom@pragma(defn)@index(rrandom)@index(uniform random))} @c{[lisp]} @itemsep compute a random real number between 0 and 1 inclusive
@end(fgroup)
@begin(pdescription)
returns @itemsep a random floating point number
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{sin(@i(expr))} @c{[sal]}
@xlcode{(sin@pragma(defn)@index(sin) @t(@i(expr)))} @c{[lisp]} @itemsep compute the sine of a number
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the floating point number
returns @itemsep the sine of the number
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{cos(@i(expr))} @c{[sal]}
@xlcode{(cos@pragma(defn)@index(cos) @t(@i(expr)))} @c{[lisp]} @itemsep compute the cosine of a number
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the floating point number
returns @itemsep the cosine of the number
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{tan(@i(expr))} @c{[sal]}
@xlcode{(tan@pragma(defn)@index(tan) @t(@i(expr)))} @c{[lisp]} @itemsep compute the tangent of a number
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the floating point number
returns @itemsep the tangent of the number
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{atan(@i(expr)[, @i(expr2)])} @c{[sal]}
@xlcode{(atan@pragma(defn)@index(atan) @t(@i(expr)) [@t(@i(expr2))])} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep compute the arctangent
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the value of @i(x)
@i<expr2> @itemsep the value of @i(y) (default value is 1.0)
returns @itemsep the arctangent of @i(x)/@i(y)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{expt(@i(x-expr), @i(y-expr))} @c{[sal]}
@xlcode{(expt@pragma(defn)@index(expt) @t(@i(x-expr)) @t(@i(y-expr)))} @c{[lisp]} @itemsep compute x to the y power
@end(fgroup)
@begin(pdescription)
@i<x-expr> @itemsep the floating point number
@i<y-expr> @itemsep the floating point exponent
returns @itemsep x to the y power
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{exp(@i(x-expr))} @c{[sal]}
@xlcode{(exp@pragma(defn)@index(exp) @t(@i(x-expr)))} @c{[lisp]} @itemsep compute e to the x power
@end(fgroup)
@begin(pdescription)
@i<x-expr> @itemsep the floating point number
returns @itemsep e to the x power
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{sqrt(@i(expr))} @c{[sal]}
@xlcode{(sqrt@pragma(defn)@index(sqrt) @t(@i(expr)))} @c{[lisp]} @itemsep compute the square root of a number
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the floating point number
returns @itemsep the square root of the number
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@xlcode{(<@pragma(defn)@index(<) @t(@i(n1)) @t(@i(n2))@r(...))} @c{[lisp]} @itemsep test for less than
@xlcode{(<=@pragma(defn)@index(<=) @t(@i(n1)) @t(@i(n2))@r(...))} @c{[lisp]} @itemsep test for less than or equal to
@xlcode{(=@pragma(defn)@index(=) @t(@i(n1)) @t(@i(n2))@r(...))} @c{[lisp]} @itemsep test for equal to
@xlcode{(/=@pragma(defn)@index(/=) @t(@i(n1)) @t(@i(n2))@r(...))} @c{[lisp]} @itemsep test for not equal to
@xlcode{(>=@pragma(defn)@index(>=) @t(@i(n1)) @t(@i(n2))@r(...))} @c{[lisp]} @itemsep test for greater than or equal to
@xlcode{(>@pragma(defn)@index(>) @t(@i(n1)) @t(@i(n2))@r(...))} @c{[lisp]} @itemsep test for greater than
@end(fgroup)
@begin(pdescription)
@i<n1> @itemsep the first number to compare
@i<n2> @itemsep the second number to compare
returns @itemsep @xlcode(t) if the results of comparing @i<n1> with @i<n2>,
@i<n2> with @i<n3>, etc., are all true.
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Bitwise Logical Functions)@index(Bitwise Logical Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{logand(@i(expr)@r(...))} @c{[sal]}
@xlcode{(logand@pragma(defn)@index(logand) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the bitwise and of a list of numbers
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the and operation
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{logior(@i(expr)@r(...))} @c{[sal]}
@xlcode{(logior@pragma(defn)@index(logior) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the bitwise inclusive or of a list of numbers
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the inclusive or operation
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{logxor(@i(expr)@r(...))} @c{[sal]}
@xlcode{(logxor@pragma(defn)@index(logxor) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep the bitwise exclusive or of a list of numbers
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the numbers
returns @itemsep the result of the exclusive or operation
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{lognot(@i(expr))} @c{[sal]}
@xlcode{(lognot@pragma(defn)@index(lognot) @t(@i(expr)))} @c{[lisp]} @itemsep the bitwise not of a number
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the number
returns @itemsep the bitwise inversion of number
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(String Functions)@index(String Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{string(@i(expr))} @c{[sal]}
@xlcode{(string@pragma(defn)@index(string) @t(@i(expr)))} @c{[lisp]} @itemsep make a string from a value
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep an integer (which is first converted into its ASCII character value), string, character, or symbol
returns @itemsep the string representation of the argument
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{string-search(@i(pat), @i(str), start: @i(start), end: @i(end))} @c{[sal]}
@xlcode{(string-search@pragma(defn)@index(string-search)@index(find string) @t(@i(pat)) @t(@i(str)) @t(&key )@t(:start) @t(:end))} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep search for pattern in string
@end(fgroup)
@begin(pdescription)
@i<pat> @itemsep a string to search for
@i<str> @itemsep the string to be searched
:start @itemsep the starting offset in str
:end @itemsep the ending offset + 1
returns @itemsep index of pat in str or NIL if not found
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{string-trim(@i(bag), @i(str))} @c{[sal]}
@xlcode{(string-trim@pragma(defn)@index(string-trim) @t(@i(bag)) @t(@i(str)))} @c{[lisp]} @itemsep trim both ends of a string
@end(fgroup)
@begin(pdescription)
@i<bag> @itemsep a string containing characters to trim
@i<str> @itemsep the string to trim
returns @itemsep a trimed copy of the string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{string-left-trim(@i(bag), @i(str))} @c{[sal]}
@xlcode{(string-left-trim@pragma(defn)@index(string-left-trim) @t(@i(bag)) @t(@i(str)))} @c{[lisp]} @itemsep trim the left end of a string
@end(fgroup)
@begin(pdescription)
@i<bag> @itemsep a string containing characters to trim
@i<str> @itemsep the string to trim
returns @itemsep a trimed copy of the string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{string-right-trim(@i(bag), @i(str))} @c{[sal]}
@xlcode{(string-right-trim@pragma(defn)@index(string-right-trim) @t(@i(bag)) @t(@i(str)))} @c{[lisp]} @itemsep trim the right end of a string
@end(fgroup)
@begin(pdescription)
@i<bag> @itemsep a string containing characters to trim
@i<str> @itemsep the string to trim
returns @itemsep a trimed copy of the string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{string-upcase(@i(str), start: @i(start), end: @i(end))} @c{[sal]}
@xlcode{(string-upcase@pragma(defn)@index(string-upcase) @t(@i(str)) @t(&key )@t(:start) @t(:end))} @c{[lisp]} @itemsep convert to uppercase
@end(fgroup)
@begin(pdescription)
@i<str> @itemsep the string
:start @itemsep the starting offset
:end @itemsep the ending offset + 1
returns @itemsep a converted copy of the string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{string-downcase(@i(str), start: @i(start), end: @i(end))} @c{[sal]}
@xlcode{(string-downcase@pragma(defn)@index(string-downcase) @t(@i(str)) @t(&key )@t(:start) @t(:end))} @c{[lisp]} @itemsep convert to lowercase
@end(fgroup)
@begin(pdescription)
@i<str> @itemsep the string
:start @itemsep the starting offset
:end @itemsep the ending offset + 1
returns @itemsep a converted copy of the string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{nstring-upcase(@i(str), start: @i(start), end: @i(end))} @c{[sal]}
@xlcode{(nstring-upcase@pragma(defn)@index(nstring-upcase) @t(@i(str)) @t(&key )@t(:start) @t(:end))} @c{[lisp]} @itemsep convert to uppercase
@end(fgroup)
@begin(pdescription)
@i<str> @itemsep the string
:start @itemsep the starting offset
:end @itemsep the ending offset + 1
returns @itemsep the converted string (not a copy)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{nstring-downcase(@i(str), start: @i(start), end: @i(end))} @c{[sal]}
@xlcode{(nstring-downcase@pragma(defn)@index(nstring-downcase) @t(@i(str)) @t(&key )@t(:start) @t(:end))} @c{[lisp]} @itemsep convert to lowercase
@end(fgroup)
@begin(pdescription)
@i<str> @itemsep the string
:start @itemsep the starting offset
:end @itemsep the ending offset + 1
returns @itemsep the converted string (not a copy)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{strcat(@i(expr)@r(...))} @c{[sal]}
@xlcode{(strcat@pragma(defn)@index(strcat)@index(concatenate strings) @t(@i(expr))@r(...))} @c{[lisp]} @itemsep concatenate strings
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the strings to concatenate
returns @itemsep the result of concatenating the strings
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{subseq(@i(string), @i(start)[, @i(end)])} @c{[sal]}
@xlcode{(subseq@pragma(defn)@index(subseq) @t(@i(string)) @t(@i(start)) [@t(@i(end))])} @c{[lisp]} @itemsep extract a substring
@end(fgroup)
@begin(pdescription)
@i<string> @itemsep the string
@i<start> @itemsep the starting position (zero origin)
@i<end> @itemsep the ending position + 1 (defaults to end)
returns @itemsep substring between @i<start> and @i<end>
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@begin(fgroup)@xlcode{string<(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string<@pragma(defn)@index(string<) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string<=(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string<=@pragma(defn)@index(string<=) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string=(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string=@pragma(defn)@index(string=) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string/=(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string/=@pragma(defn)@index(string/=) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string>=(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string>=@pragma(defn)@index(string>=) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string>(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string>@pragma(defn)@index(string>) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@end(fgroup)
@begin(pdescription)
@i<str1> @itemsep the first string to compare
@i<str2> @itemsep the second string to compare
:start1 @itemsep first substring starting offset
:end1 @itemsep first substring ending offset + 1
:start2 @itemsep second substring starting offset
:end2 @itemsep second substring ending offset + 1
returns @itemsep @xlcode(t) if predicate is true, @xlcode(nil) otherwise
Note: case is significant with these comparison functions.
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@begin(fgroup)@xlcode{string-lessp(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string-lessp@pragma(defn)@index(string-lessp) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string-not-greaterp(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string-not-greaterp@pragma(defn)@index(string-not-greaterp) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string-equalp(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string-equalp@pragma(defn)@index(string-equalp) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string-not-equalp(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string-not-equalp@pragma(defn)@index(string-not-equalp) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string-not-lessp(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string-not-lessp@pragma(defn)@index(string-not-lessp) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{string-greaterp(@i(str1), @i(str2), start1: @i(start1), end1: @i(end1), start2: @i(start2), end2: @i(end2))} @c{[sal]}
@xlcode{(string-greaterp@pragma(defn)@index(string-greaterp) @t(@i(str1)) @t(@i(str2)) @t(&key )@t(:start1) @t(:end1) @t(:start2) @t(:end2))} @c{[lisp]}
@end(fgroup)
@end(fgroup)
@begin(pdescription)
@i<str1> @itemsep the first string to compare
@i<str2> @itemsep the second string to compare
:start1 @itemsep first substring starting offset
:end1 @itemsep first substring ending offset + 1
:start2 @itemsep second substring starting offset
:end2 @itemsep second substring ending offset + 1
returns @itemsep @xlcode(t) if predicate is true, @xlcode(nil) otherwise
Note: case is not significant with these comparison functions.
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Character Functions)@index(Character Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{char(@i(string), @i(index))} @c{[sal]}
@xlcode{(char@pragma(defn)@index(char) @t(@i(string)) @t(@i(index)))} @c{[lisp]} @itemsep extract a character from a string
@end(fgroup)
@begin(pdescription)
@i<string> @itemsep the string
@i<index> @itemsep the string index (zero relative)
returns @itemsep the ascii code of the character
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{upper-case-p(@i(chr))} @c{[sal]}
@xlcode{(upper-case-p@pragma(defn)@index(upper-case-p) @t(@i(chr)))} @c{[lisp]} @itemsep is this an upper case character?
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep @xlcode(t) if the character is upper case, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{lower-case-p(@i(chr))} @c{[sal]}
@xlcode{(lower-case-p@pragma(defn)@index(lower-case-p) @t(@i(chr)))} @c{[lisp]} @itemsep is this a lower case character?
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep @xlcode(t) if the character is lower case, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{both-case-p(@i(chr))} @c{[sal]}
@xlcode{(both-case-p@pragma(defn)@index(both-case-p) @t(@i(chr)))} @c{[lisp]} @itemsep is this an alphabetic (either case) character?
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep @xlcode(t) if the character is alphabetic, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{digit-char-p(@i(chr))} @c{[sal]}
@xlcode{(digit-char-p@pragma(defn)@index(digit-char-p) @t(@i(chr)))} @c{[lisp]} @itemsep is this a digit character?
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep the digit weight if character is a digit, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{char-code(@i(chr))} @c{[sal]}
@xlcode{(char-code@pragma(defn)@index(char-code) @t(@i(chr)))} @c{[lisp]} @itemsep get the ascii code of a character
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep the ascii character code (integer)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{code-char(@i(code))} @c{[sal]}
@xlcode{(code-char@pragma(defn)@index(code-char) @t(@i(code)))} @c{[lisp]} @itemsep get the character with a specified ascii code
@end(fgroup)
@begin(pdescription)
@i<code> @itemsep the ascii code (integer)
returns @itemsep the character with that code or @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{char-upcase(@i(chr))} @c{[sal]}
@xlcode{(char-upcase@pragma(defn)@index(char-upcase) @t(@i(chr)))} @c{[lisp]} @itemsep convert a character to upper case
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep the upper case character
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{char-downcase(@i(chr))} @c{[sal]}
@xlcode{(char-downcase@pragma(defn)@index(char-downcase) @t(@i(chr)))} @c{[lisp]} @itemsep convert a character to lower case
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep the lower case character
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{digit-char(@i(n))} @c{[sal]}
@xlcode{(digit-char@pragma(defn)@index(digit-char) @t(@i(n)))} @c{[lisp]} @itemsep convert a digit weight to a digit
@end(fgroup)
@begin(pdescription)
@i<n> @itemsep the digit weight (integer)
returns @itemsep the digit character or @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{char-int(@i(chr))} @c{[sal]}
@xlcode{(char-int@pragma(defn)@index(char-int) @t(@i(chr)))} @c{[lisp]} @itemsep convert a character to an integer
@end(fgroup)
@begin(pdescription)
@i<chr> @itemsep the character
returns @itemsep the ascii character code
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{int-char(@i(int))} @c{[sal]}
@xlcode{(int-char@pragma(defn)@index(int-char) @t(@i(int)))} @c{[lisp]} @itemsep convert an integer to a character
@end(fgroup)
@begin(pdescription)
@i<int> @itemsep the ascii character code
returns @itemsep the character with that code
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@begin(fgroup)@xlcode{char<(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char<@pragma(defn)@index(char<) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char<=(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char<=@pragma(defn)@index(char<=) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char=(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char=@pragma(defn)@index(char=) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char/=(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char/=@pragma(defn)@index(char/=) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char>=(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char>=@pragma(defn)@index(char>=) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char>(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char>@pragma(defn)@index(char>) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@end(fgroup)
@begin(pdescription)
@i<chr1> @itemsep the first character to compare
@i<chr2> @itemsep the second character(s) to compare
returns @itemsep @xlcode(t) if predicate is true, @xlcode(nil) otherwise
Note: case is significant with these comparison functions.
@end(pdescription)
@blankspace(1)
@begin(fgroup)
@begin(fgroup)@xlcode{char-lessp(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char-lessp@pragma(defn)@index(char-lessp) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char-not-greaterp(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char-not-greaterp@pragma(defn)@index(char-not-greaterp) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char-equalp(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char-equalp@pragma(defn)@index(char-equalp) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char-not-equalp(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char-not-equalp@pragma(defn)@index(char-not-equalp) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char-not-lessp(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char-not-lessp@pragma(defn)@index(char-not-lessp) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@pragma(endcodef)
@begin(fgroup)@xlcode{char-greaterp(@i(chr1), @i(chr2)@r(...))} @c{[sal]}
@xlcode{(char-greaterp@pragma(defn)@index(char-greaterp) @t(@i(chr1)) @t(@i(chr2))@r(...))} @c{[lisp]}
@end(fgroup)
@end(fgroup)
@begin(pdescription)
@i<chr1> @itemsep the first string to compare
@i<chr2> @itemsep the second string(s) to compare
returns @itemsep @xlcode(t) if predicate is true, @xlcode(nil) otherwise
Note: case is not significant with these comparison functions.
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(Input/Output Functions)@index(Input/Output Functions)
@begin(fdescription)
@begin(fgroup)@xlcode{read([@i(stream)[, @i(eof)[, @i(rflag)]]])} @c{[sal]}
@xlcode{(read@pragma(defn)@index(read) [@t(@i(stream)) [@t(@i(eof)) [@t(@i(rflag))]]])} @c{[lisp]} @itemsep read an expression
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the input stream (default is standard input)
@i<eof> @itemsep the value to return on end of file (default is @xlcode(nil))
@i<rflag> @itemsep recursive read flag (default is @xlcode(nil))
returns @itemsep the expression read
@end(pdescription)
@blankspace(1)
@xlcode{(print@pragma(defn)@index(print) @t(@i(expr)) [@t(@i(stream))])} @c{[lisp]} @itemsep print an expression on a new line
@begin(pdescription)
@i<expr> @itemsep the expression to be printed
@i<stream> @itemsep the output stream (default is standard output)
returns @itemsep the expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{prin1(@i(expr)[, @i(stream)])} @c{[sal]}
@xlcode{(prin1@pragma(defn)@index(prin1) @t(@i(expr)) [@t(@i(stream))])} @c{[lisp]} @itemsep print an expression
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to be printed
@i<stream> @itemsep the output stream (default is standard output)
returns @itemsep the expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{princ(@i(expr)[, @i(stream)])} @c{[sal]}
@xlcode{(princ@pragma(defn)@index(princ) @t(@i(expr)) [@t(@i(stream))])} @c{[lisp]} @itemsep print an expression without quoting
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expressions to be printed
@i<stream> @itemsep the output stream (default is standard output)
returns @itemsep the expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{pprint(@i(expr)[, @i(stream)])} @c{[sal]}
@xlcode{(pprint@pragma(defn)@index(pprint) @t(@i(expr)) [@t(@i(stream))])} @c{[lisp]} @itemsep pretty print an expression
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expressions to be printed
@i<stream> @itemsep the output stream (default is standard output)
returns @itemsep the expression
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{terpri([@i(stream)])} @c{[sal]}
@xlcode{(terpri@pragma(defn)@index(terpri) [@t(@i(stream))])} @c{[lisp]} @itemsep terminate the current print line
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the output stream (default is standard output)
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{flatsize(@i(expr))} @c{[sal]}
@xlcode{(flatsize@pragma(defn)@index(flatsize) @t(@i(expr)))} @c{[lisp]} @itemsep length of printed representation using prin1
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression
returns @itemsep the length
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{flatc(@i(expr))} @c{[sal]}
@xlcode{(flatc@pragma(defn)@index(flatc) @t(@i(expr)))} @c{[lisp]} @itemsep length of printed representation using princ
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression
returns @itemsep the length
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(The Format Function)@index(The Format Function)
@begin(fdescription)
@begin(fgroup)@xlcode{format(@i(stream), @i(fmt), @i(arg)@r(...))} @c{[sal]}
@xlcode{(format@pragma(defn)@index(format) @t(@i(stream)) @t(@i(fmt)) @t(@i(arg))@r(...))} @c{[lisp]} @itemsep do formated
@end(fgroup)
output
@begin(pdescription)
@i<stream> @itemsep the output stream
@i<fmt> @itemsep the format string
@i<arg> @itemsep the format arguments
returns @itemsep output string if @i<stream> is @xlcode(nil), @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@end(fdescription)
The format string can contain characters that should be copied
directly to the output and formatting directives. The
formatting directives are:
@begin(display)
@xlcode(~A) @itemsep print next argument using princ
@xlcode(~S) @itemsep print next argument using prin1
@xlcode(~%) @itemsep start a new line
@xlcode(~~) @itemsep print a tilde character
@xlcode(~)<newline> @itemsep ignore this one newline and white space on the
next line up to the first non-white-space character or newline. This
allows strings to continue across multiple lines
@end(display)
@section(File I/O Functions)@index(File I/O Functions)
Note that files are ordinarily opened as text. Binary files (such as standard midi files) must be opened with @xlcode(open-binary) on non-unix systems.
@begin(fdescription)
@begin(fgroup)@xlcode{open(@i(fname), direction: @i(direction))} @c{[sal]}
@xlcode{(open@pragma(defn)@index(open) @t(@i(fname)) @t(&key )@t(:direction))} @c{[lisp]} @itemsep open a file stream
@end(fgroup)
@begin(pdescription)
@i<fname> @itemsep the file name string or symbol
:direction @itemsep :input or :output (default is :input)
returns @itemsep a stream
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{open-binary(@i(fname), direction: @i(direction))} @c{[sal]}
@xlcode{(open-binary@pragma(defn)@index(open-binary)@index(open)@index(binary files) @t(@i(fname)) @t(&key )@t(:direction))} @c{[lisp]} @itemsep open a binary file stream
@end(fgroup)
@begin(pdescription)
@i<fname> @itemsep the file name string or symbol
:direction @itemsep :input or :output (default is :input)
returns @itemsep a stream
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{close(@i(stream))} @c{[sal]}
@xlcode{(close@pragma(defn)@index(close) @t(@i(stream)))} @c{[lisp]} @itemsep close a file stream
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the stream
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{setdir(@i(path)[, @i(verbose)])} @c{[sal]}
@xlcode{(setdir@pragma(defn)@index(setdir)@index(change directory) @t(@i(path)) [@t(@i(verbose))])} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep set current directory
@end(fgroup)
@begin(pdescription)
@i<path> @itemsep the path of the new directory
@i<verbose> @itemsep print error message if current directory cannot be changed to @i(path)
returns @itemsep the resulting full path, e.g. (setdir ".") gets the current working directory, or @xlcode(nil) if an error occurs
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{listdir(@i(path))} @c{[sal]}
@xlcode{(listdir@pragma(defn)@index(listdir)@index(directory listing)@index(scan directory)@index(read directory)@index(list directory) @t(@i(path)))} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep get a directory listing
@end(fgroup)
@begin(pdescription)
@i<path> @itemsep the path of the directory to be listed
returns @itemsep list of filenames in the directory
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{get-temp-path()} @c{[sal]}
@xlcode{(get-temp-path@pragma(defn)@index(get-temp-path)@index(temporary files)@index(temp file))} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep get a path where a temporary file can be created. Under Windows, this is based on environment variables. If XLISP is running as a sub-process to Java, the environment may not exist, in which case the default result is the unfortunate choice @xlcode(c:\windows\).
@end(fgroup)
@begin(pdescription)
returns @itemsep the resulting full path as a string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{get-user()} @c{[sal]}
@xlcode{(get-user@pragma(defn)@index(get-user)@index(user name)@index(temp file))} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep get the user ID. In Unix systems (including OS X and Linux), this is the value of the USER environment variable. In Windows, this is currently just ``nyquist'', which is also returned if the environment variable cannot be accessed. This function is used to avoid the case of two users creating files of the same name in the same temp directory.
@end(fgroup)
@begin(pdescription)
returns @itemsep the string naming the user
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{find-in-xlisp-path(@i(filename))} @c{[sal]}
@xlcode{(find-in-xlisp-path@pragma(defn)@index(find-in-xlisp-path) @t(@i(filename)))} @c{[lisp]}@foot(This is not a standard XLISP 2.0 function.) @itemsep search the XLISP search path (e.g. @xlcode(XLISPPATH) from the environment) for @i(filename). If @i(filename) is not found as is, and there is no file extension, append "@code(.lsp)" to @i(filename) and search again. The current directory is not searched.
@end(fgroup)
@begin(pdescription)
@i<filename> @itemsep the name of the file to search for
returns @itemsep a full path name to the first occurrence found
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{read-char([@i(stream)])} @c{[sal]}
@xlcode{(read-char@pragma(defn)@index(read-char)@index(get char) [@t(@i(stream))])} @c{[lisp]} @itemsep read a character from a stream
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the input stream (default is standard input)
returns @itemsep the character
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{peek-char([@i(flag)[, @i(stream)]])} @c{[sal]}
@xlcode{(peek-char@pragma(defn)@index(peek-char) [@t(@i(flag)) [@t(@i(stream))]])} @c{[lisp]} @itemsep peek at the next character
@end(fgroup)
@begin(pdescription)
@i<flag> @itemsep flag for skipping white space (default is @xlcode(nil))
@i<stream> @itemsep the input stream (default is standard input)
returns @itemsep the character (integer)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{write-char(@i(ch)[, @i(stream)])} @c{[sal]}
@xlcode{(write-char@pragma(defn)@index(write-char) @t(@i(ch)) [@t(@i(stream))])} @c{[lisp]} @itemsep write a character to a stream
@end(fgroup)
@begin(pdescription)
@i<ch> @itemsep the character to write
@i<stream> @itemsep the output stream (default is standard output)
returns @itemsep the character
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{read-int([@i(stream)[, @i(length)]])} @c{[sal]}
@xlcode{(read-int@pragma(defn)@index(read-int) [@t(@i(stream)) [@t(@i(length))]])} @c{[lisp]} @itemsep read a binary integer from a stream
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the input stream (default is standard input)
@i<length> @itemsep the length of the integer in bytes (default is 4)
returns @itemsep the integer
Note: Integers are assumed to be big-endian (high-order byte first) and
signed, regardless of the platform. To read little-endian format, use a
negative number for the length, e.g. -4 indicates a 4-bytes, low-order
byte first. The file should be opened in binary mode.
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{write-int(@i(ch)[, @i(stream)[, @i(length)]])} @c{[sal]}
@xlcode{(write-int@pragma(defn)@index(write-int) @t(@i(ch)) [@t(@i(stream)) [@t(@i(length))]])} @c{[lisp]} @itemsep write a binary integer to a stream
@end(fgroup)
@begin(pdescription)
@i<ch> @itemsep the character to write
@i<stream> @itemsep the output stream (default is standard output)
@i<length> @itemsep the length of the integer in bytes (default is 4)
returns @itemsep the integer
Note: Integers are assumed to be big-endian (high-order byte first) and
signed, regardless of the platform. To write in little-endian format, use a
negative number for the length, e.g. -4 indicates a 4-bytes, low-order
byte first. The file should be opened in binary mode.
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{read-float([@i(stream)[, @i(length)]])} @c{[sal]}
@xlcode{(read-float@pragma(defn)@index(read-float) [@t(@i(stream)) [@t(@i(length))]])} @c{[lisp]} @itemsep read a binary floating-point number from a stream
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the input stream (default is standard input)
@i<length> @itemsep the length of the float in bytes (default is 4, legal values are -4, -8, 4, and 8)
returns @itemsep the integer
Note: Floats are assumed to be big-endian (high-order byte first) and
signed, regardless of the platform. To read little-endian format, use a
negative number for the length, e.g. -4 indicates a 4-bytes, low-order
byte first. The file should be opened in binary mode.
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{write-float(@i(ch)[, @i(stream)[, @i(length)]])} @c{[sal]}
@xlcode{(write-float@pragma(defn)@index(write-float) @t(@i(ch)) [@t(@i(stream)) [@t(@i(length))]])} @c{[lisp]} @itemsep write a binary floating-point number to a stream
@end(fgroup)
@begin(pdescription)
@i<ch> @itemsep the character to write
@i<stream> @itemsep the output stream (default is standard output)
@i<length> @itemsep the length of the float in bytes (default is 4, legal values are -4, -8, 4, and 8)
returns @itemsep the integer
Note: Floats are assumed to be big-endian (high-order byte first) and
signed, regardless of the platform. To write in little-endian format, use a
negative number for the length, e.g. -4 indicates a 4-bytes, low-order
byte first. The file should be opened in binary mode.
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{read-line([@i(stream)])} @c{[sal]}
@xlcode{(read-line@pragma(defn)@index(read-line) [@t(@i(stream))])} @c{[lisp]} @itemsep read a line from a stream
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the input stream (default is standard input)
returns @itemsep the string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{read-byte([@i(stream)])} @c{[sal]}
@xlcode{(read-byte@pragma(defn)@index(read-byte) [@t(@i(stream))])} @c{[lisp]} @itemsep read a byte from a stream
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the input stream (default is standard input)
returns @itemsep the byte (integer)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{write-byte(@i(byte)[, @i(stream)])} @c{[sal]}
@xlcode{(write-byte@pragma(defn)@index(write-byte) @t(@i(byte)) [@t(@i(stream))])} @c{[lisp]} @itemsep write a byte to a stream
@end(fgroup)
@begin(pdescription)
@i<byte> @itemsep the byte to write (integer)
@i<stream> @itemsep the output stream (default is standard output)
returns @itemsep the byte (integer)
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(String Stream Functions)@index(String Stream Functions)
These functions operate on unnamed streams. An unnamed output
stream collects characters sent to it when it is used as the
destination of any output function. The functions
@xlcode(get-output-stream-string) and @xlcode(get-output-stream-list) return a string or a list of characters.
An unnamed input stream is setup with the
@xlcode(make-string-input-stream) function and returns each character of the string when
it is used as the source of any input function.
@begin(fdescription)
@blankspace(1)
@begin(fgroup)@xlcode{make-string-input-stream(@i(str)[, @i(start)[, @i(end)]])} @c{[sal]}
@xlcode{(make-string-input-stream@pragma(defn)@index(make-string-input-stream) @t(@i(str)) [@t(@i(start)) [@t(@i(end))]])} @c{[lisp]}
@end(fgroup)
@begin(pdescription)
@i<str> @itemsep the string
@i<start> @itemsep the starting offset
@i<end> @itemsep the ending offset + 1
returns @itemsep an unnamed stream that reads from the string
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{make-string-output-stream)()} @c{[sal]}
@xlcode{(make-string-output-stream)} @c{[lisp]}@pragma(defn)@index(make-string-output-stream)
@end(fgroup)
@begin(pdescription)
returns @itemsep an unnamed output stream
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{get-output-stream-string(@i(stream))} @c{[sal]}
@xlcode{(get-output-stream-string@pragma(defn)@index(get-output-stream-string) @t(@i(stream)))} @c{[lisp]}
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the output stream
returns @itemsep the output so far as a string
Note: the output stream is emptied by this function
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{get-output-stream-list(@i(stream))} @c{[sal]}
@xlcode{(get-output-stream-list@pragma(defn)@index(get-output-stream-list) @t(@i(stream)))} @c{[lisp]}
@end(fgroup)
@begin(pdescription)
@i<stream> @itemsep the output stream
returns @itemsep the output so far as a list
Note: the output stream is emptied by this function
@end(pdescription)
@blankspace(1)
@end(fdescription)
@section(System Functions)@index(System Functions)
Note: the @xlcode(load) function first tries to load a file from the current directory. A @code(.lsp) extension is added if there is not already an alphanumeric extension following a period. If that fails, XLISP searches the path, which is obtained from the XLISPPATH environment variable in Unix and HKEY_LOCAL_MACHINE\SOFTWARE\CMU\Nyquist\XLISPPATH under Win32. (The Macintosh version has no search path.)
@begin(fdescription)
@begin(fgroup)@xlcode{get-env(@i(name))} @c{[sal]}
@xlcode{(get-env@pragma(defn)@index(get-env)@index(getenv)@index(environment variables) @t(@i(name)))} @c{[lisp]} @itemsep get from an environment variable
@end(fgroup)
@begin(pdescription)
@i<name> @itemsep the name of the environment variable
returns @itemsep string value of the environment variable, @xlcode(nil) if variable does not exist
@end(pdescription)
@blankspace(1)
@xlcode{(load@pragma(defn)@index(load) @t(@i(fname)) @t(&key )@t(:verbose) @t(:print))} @c{[lisp]} @itemsep load a source file
@begin(pdescription)
@i<fname> @itemsep the filename string or symbol
:verbose @itemsep the verbose flag (default is t)
:print @itemsep the print flag (default is @xlcode(nil))
returns @itemsep the filename
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{save(@i(fname))} @c{[sal]}
@xlcode{(save@pragma(defn)@index(save) @t(@i(fname)))} @c{[lisp]} @itemsep save workspace to a file
@end(fgroup)
@begin(pdescription)
@i<fname> @itemsep the filename string or symbol
returns @itemsep @xlcode(t) if workspace was written, @xlcode(nil) otherwise
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{restore(@i(fname))} @c{[sal]}
@xlcode{(restore@pragma(defn)@index(restore) @t(@i(fname)))} @c{[lisp]} @itemsep restore workspace from a file
@end(fgroup)
@begin(pdescription)
@i<fname> @itemsep the filename string or symbol
returns @itemsep @xlcode(nil) on failure, otherwise never returns
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{dribble([@i(fname)])} @c{[sal]}
@xlcode{(dribble@pragma(defn)@index(dribble) [@t(@i(fname))])} @c{[lisp]} @itemsep create a file with a transcript of a session
@end(fgroup)
@begin(pdescription)
@i<fname> @itemsep file name string or symbol
(if missing, close current transcript)
returns @itemsep @xlcode(t) if the transcript is opened, @xlcode(nil) if it is closed
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{gc()} @c{[sal]}
@xlcode{(gc@pragma(defn)@index(gc))} @c{[lisp]} @itemsep force garbage collection
@end(fgroup)
@begin(pdescription)
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{expand(@i(num))} @c{[sal]}
@xlcode{(expand@pragma(defn)@index(expand) @t(@i(num)))} @c{[lisp]} @itemsep expand memory by adding segments
@end(fgroup)
@begin(pdescription)
@i<num> @itemsep the number of segments to add
returns @itemsep the number of segments added
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{alloc(@i(num))} @c{[sal]}
@xlcode{(alloc@pragma(defn)@index(alloc) @t(@i(num)))} @c{[lisp]} @itemsep change number of nodes to allocate in each segment
@end(fgroup)
@begin(pdescription)
@i<num> @itemsep the number of nodes to allocate
returns @itemsep the old number of nodes to allocate
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{info()} @c{[sal]}
@xlcode{(info@pragma(defn)@index(info))} @c{[lisp]} @itemsep show information about memory usage.
@end(fgroup)
@begin(pdescription)
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{room()} @c{[sal]}
@xlcode{(room@pragma(defn)@index(room))} @c{[lisp]} @itemsep show memory allocation statistics
@end(fgroup)
@begin(pdescription)
returns @itemsep @xlcode(nil)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{type-of(@i(expr))} @c{[sal]}
@xlcode{(type-of@pragma(defn)@index(type-of) @t(@i(expr)))} @c{[lisp]} @itemsep returns the type of the expression
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the expression to return the type of
returns @itemsep @xlcode(nil) if the value is @xlcode(nil) otherwise one of the symbols:
@begin(pdescription)
SYMBOL @itemsep for symbols
OBJECT @itemsep for objects
CONS @itemsep for conses
SUBR @itemsep for built-in functions
FSUBR @itemsep for special forms
CLOSURE @itemsep for defined functions
STRING @itemsep for strings
FIXNUM @itemsep for integers
FLONUM @itemsep for floating point numbers
CHARACTER @itemsep for characters
FILE-STREAM @itemsep for file pointers
UNNAMED-STREAM @itemsep for unnamed streams
ARRAY @itemsep for arrays
@end(pdescription)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{peek(@i(addrs))} @c{[sal]}
@xlcode{(peek@pragma(defn)@index(peek) @t(@i(addrs)))} @c{[lisp]} @itemsep peek at a location in memory
@end(fgroup)
@begin(pdescription)
@i<addrs> @itemsep the address to peek at (integer)
returns @itemsep the value at the specified address (integer)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{poke(@i(addrs), @i(value))} @c{[sal]}
@xlcode{(poke@pragma(defn)@index(poke) @t(@i(addrs)) @t(@i(value)))} @c{[lisp]} @itemsep poke a value into memory
@end(fgroup)
@begin(pdescription)
@i<addrs> @itemsep the address to poke (integer)
@i<value> @itemsep the value to poke into the address (integer)
returns @itemsep the value
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{bigendianp()} @c{[sal]}
@xlcode{(bigendianp@pragma(defn)@index(bigendianp)@index(endian)@index(big endian)@index(little endian))} @c{[lisp]} @itemsep is this a big-endian machine?
@end(fgroup)
@begin(pdescription)
returns @itemsep T if this a big-endian architecture, storing the high-order byte of an integer at the lowest byte address of the integer; otherwise, NIL.
@foot(This is not a standard XLISP 2.0 function.)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{address-of(@i(expr))} @c{[sal]}
@xlcode{(address-of@pragma(defn)@index(address-of) @t(@i(expr)))} @c{[lisp]} @itemsep get the address of an xlisp node
@end(fgroup)
@begin(pdescription)
@i<expr> @itemsep the node
returns @itemsep the address of the node (integer)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{exit()} @c{[sal]}
@xlcode{(exit@pragma(defn)@index(exit))} @c{[lisp]} @itemsep exit xlisp
@end(fgroup)
@begin(pdescription)
returns @itemsep never returns
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{setup-console()} @c{[sal]}
@xlcode{(setup-console@pragma(defn)@index(setup-console)@index(window initialization))} @c{[lisp]} @itemsep set default console attributes
@end(fgroup)
@begin(pdescription)
returns @itemsep NIL
Note: Under Windows, Nyquist normally starts up in a medium-sized console window with black text and a white background, with a window title of ``Nyquist.'' This is normally accomplished by calling @xlcode(setup-console) in @code(system.lsp). In Nyquist, you can avoid this behavior by setting @xlcode(*setup-console*) to NIL in your @code(init.lsp) file. If @xlcode(setup-console) is not called, Nyquist uses standard input and output as is. This is what you want if you are running Nyquist inside of emacs, for example.@index(emacs, using Nyquist with)
@end(pdescription)
@blankspace(1)
@begin(fgroup)@xlcode{echoenabled(@i(flag))} @c{[sal]}
@xlcode{(echoenabled@pragma(defn)@index(echoenabled)@index(console, XLISP) @t(@i(flag)))} @c{[lisp]} @itemsep turn console input echoing on or off
@end(fgroup)
@begin(pdescription)
@i<flag> @itemsep T to enable echo, NIL to disable
returns @itemsep NIL
Note: This function is only implemented under Linux and Mac OS X. If Nyquist I/O is redirected through pipes,
the Windows version does not echo the input, but the Linux and Mac versions do. You can turn off echoing with
this function. Under windows it is defined to do nothing.
@end(pdescription)
@end(fdescription)
@section(File I/O Functions)@index(File I/O Functions)
@subsection(Input from a File)@index(Input from a File)
To open a file for input, use the @xlcode(open) function with the keyword
argument @xlcode(:direction) set to @xlcode(:input). To open a file for output,
use the @xlcode(open) function with the keyword argument @xlcode(:direction) set
to @xlcode(:output). The @xlcode(open) function takes a single required argument which
is the name of the file to be opened. This name can be in the form of a
string or a symbol. The @xlcode(open) function returns an object of type
@xlcode(FILE-STREAM) if it succeeds in opening the specified file. It returns the
value @xlcode(nil) if it fails. In order to manipulate the file, it is
necessary to save the value returned by the @xlcode(open) function. This is
usually done by assigning it to a variable with the @xlcode(setq) special form or by
binding it using @xlcode(let) or @xlcode(let*). Here is an example:
@begin(example)
(setq fp (open "init.lsp" :direction :input))
@end(example)
Evaluating this expression will result in the file @code(init.lsp)
being opened. The file object that will be returned by the @xlcode(open)
function will be assigned to the variable @xlcode(fp).
It is now possible to use the file for input. To read an
expression from the file, just supply the value of the @xlcode(fp)
variable as the optional @i(stream) argument to @xlcode(read).
@begin(example)
(read fp)
@end(example)
Evaluating this expression will result in reading the first
expression from the file @code(init.lsp). The expression will be
returned as the result of the @xlcode(read) function. More expressions
can be read from the file using further calls to the @xlcode(read)
function. When there are no more expressions to read, the @xlcode(read)
function will return @xlcode(nil) (or whatever value was supplied as the
second argument to @xlcode(read)).
Once you are done reading from the file, you should close it.
To close the file, use the following expression:
@begin(example)
(close fp)
@end(example)
Evaluating this expression will cause the file to be closed.
@subsection(Output to a File)@index(Output to a File)
Writing to a file is pretty much the same as reading from one.
You need to open the file first. This time you should use the
@xlcode(open) function to indicate that you will do output to the file.
For example:
@begin(example)
(setq fp (open "test.dat" :direction :output))
@end(example)
Evaluating this expression will open the file @code(test.dat) for
output. If the file already exists, its current contents will
be discarded. If it doesn't already exist, it will be created.
In any case, a @xlcode(FILE-STREAM) object will be returned by the @xlcode(OPEN)
function. This file object will be assigned to the @xlcode(fp)
variable.
It is now possible to write to this file by supplying the value
of the @xlcode(fp) variable as the optional @i(stream) parameter in the @xlcode(print) function.
@begin(example)
(print "Hello there" fp)
@end(example)
Evaluating this expression will result in the string ``Hello
there'' being written to the file @code(test.dat). More data can be
written to the file using the same technique.
Once you are done writing to the file, you should close it.
Closing an output file is just like closing an input file.
@begin(example)
(close fp)
@end(example)
Evaluating this expression will close the output file and make
it permanent.
@subsection(A Slightly More Complicated File Example)
This example shows how to open a file, read each Lisp expression
from the file and print it. It demonstrates the use of files
and the use of the optional @i(stream) argument to the @xlcode(read)
function.
@begin(programexample)
(do* ((fp (open "test.dat" :direction :input))
(ex (read fp) (read fp)))
((null ex) nil)
(print ex))
@end(programexample)
|