File: usermanual_8.html

package info (click to toggle)
ucblogo 6.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,636 kB
  • sloc: ansic: 16,989; cpp: 3,818; makefile: 186; perl: 3
file content (1986 lines) | stat: -rw-r--r-- 116,860 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on September, 3 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>

-->
<head>
<title>BERKELEY LOGO 6.0: 8. Control Structures</title>

<meta name="description" content="BERKELEY LOGO 6.0: 8. Control Structures">
<meta name="keywords" content="BERKELEY LOGO 6.0: 8. Control Structures">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="CONTROL-STRUCTURES"></a>
<a name="SEC320"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="usermanual_7.html#SEC319" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual_7.html#SEC231" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 8. Control Structures </h1>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC321">8.1 Control</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC353">8.2 Template-based Iteration</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">    
</td></tr>
</table>


<hr size="6">
<a name="CONTROL"></a>
<a name="SEC321"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC320" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC322" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC320" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 8.1 Control </h2>

<p>Note: in the following descriptions, an <em>instructionlist</em> can be a list or
a word.  In the latter case, the word is parsed into list form before it is
run.  Thus, <tt>RUN READWORD</tt> or <tt>RUN READLIST</tt> will work.  The
former is slightly preferable because it allows for a continued line (with <code>~</code>)
that includes a comment (with <code>;</code>) on the first line.
</p>
<p>A <var>tf</var> input must be the word <code>TRUE</code>, the word <code>FALSE</code>, or a list.  If it's a
list, then it must be a Logo expression, which will be evaluated to produce
a value that must be <code>TRUE</code> or <code>FALSE</code>.  The comparisons with <code>TRUE</code> and <code>FALSE</code>
are always case-insensitive.
</p>
<p>A runlist can consist of either a single expression (that produces a value)
or zero or more instructions (that do something, rather than output a value),
depending on the context:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">PRINT IFELSE :X&lt;0 [&quot;NEGATIVE] [&quot;POSITIVE]  ; one value in each case
REPEAT 4 [PRINT &quot;A PRINT &quot;B]  ; two instructions
</pre></td></tr></table>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC322">run</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                         
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC323">runresult</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                   
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC324">repeat</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC325">forever</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC326">repcount</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC327">if</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                          
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC328">ifelse</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC329">test</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                        
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC330">iftrue</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC331">iffalse</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC332">stop</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                        
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC333">output</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC334">catch</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC335">throw</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC336">error</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC337">pause</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC338">continue</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC339">wait</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                        
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC340">bye</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                         
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC341">.maybeoutput</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                MAYBEOUTPUT
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC342">goto</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                        
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC343">tag</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                         
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC344">ignore</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC345">`</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC346">for</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                         
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC347">do.while</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    DO.WHILE
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC348">while</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC349">do.until</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    DO.UNTIL
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC350">until</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC351">case</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                        
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC352">cond</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                        
</td></tr>
</table>

<hr size="6">
<a name="RUN"></a>
<a name="SEC322"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC321" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC323" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> run </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">RUN instructionlist
</pre></td></tr></table>

<p>command or operation.  Runs the Logo instructions in the input list;
outputs if the list contains an expression that outputs.
</p>
<p>See section <a href="usermanual_3.html#SEC74">readword</a> ,
<a href="usermanual_3.html#SEC73">readlist</a> .
</p>
<hr size="6">
<a name="RUNRESULT"></a>
<a name="SEC323"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC322" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC324" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> runresult </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">RUNRESULT instructionlist
</pre></td></tr></table>

<p>runs the instructions in the input; outputs an empty list if those
instructions produce no output, or a list whose only member is the
output from running the input instructionlist.  Useful for inventing
command-or-operation control structures:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">local &quot;result
make &quot;result runresult [something]
if emptyp :result [stop]
output first :result
</pre></td></tr></table>

<hr size="6">
<a name="REPEAT"></a>
<a name="SEC324"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC323" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC325" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> repeat </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">REPEAT num instructionlist
</pre></td></tr></table>

<p>command.  Runs the <var>instructionlist</var> repeatedly, <var>num</var> times.
</p>
<hr size="6">
<a name="FOREVER"></a>
<a name="SEC325"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC324" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC326" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> forever </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">FOREVER instructionlist
</pre></td></tr></table>

<p>command.  Runs the &quot;instructionlist&quot; repeatedly, until something inside
the instructionlist (such as <code>STOP</code> or <code>THROW</code>) makes it stop.
</p>
<p>See section <a href="#SEC332">stop</a> ,
See section <a href="#SEC335">throw</a> .
</p>

<hr size="6">
<a name="REPCOUNT"></a>
<a name="SEC326"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC325" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC327" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> repcount </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">REPCOUNT
</pre></td></tr></table>

<p>outputs the repetition count of the innermost current <code>REPEAT</code> or
<code>FOREVER</code>, starting from 1.  If no <code>REPEAT</code> or <code>FOREVER</code>
is active, outputs &ndash;1.
</p>
<p>The abbreviation <code>#</code> can be used for <code>REPCOUNT</code> unless the
<code>REPEAT</code> is inside the template input to a higher order procedure
such as <code>FOREACH</code>, in which case <code>#</code> has a different meaning.
</p>
<hr size="6">
<a name="IF"></a>
<a name="SEC327"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC326" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC328" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> if </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">IF tf instructionlist
(IF tf instructionlist1 instructionlist2)
</pre></td></tr></table>

<p>command.  If the first input has the value <code>TRUE</code>, then <code>IF</code> runs the second
input.  If the first input has the value <code>FALSE</code>, then <code>IF</code> does nothing.
(If given a third input, IF acts like <code>IFELSE</code>, as described below.)  It
is an error if the first input is not either <code>TRUE</code> or <code>FALSE</code>.
</p>
<p>For compatibility with earlier versions of Logo, if an <code>IF</code> instruction is
not enclosed in parentheses, but the first thing on the instruction line
after the second input expression is a literal list (i.e., a list in
square brackets), the <code>IF</code> is treated as if it were <code>IFELSE</code>, but a warning
message is given.  If this aberrant <code>IF</code> appears in a procedure body, the
warning is given only the first time the procedure is invoked in each
Logo session.
</p>
<hr size="6">
<a name="IFELSE"></a>
<a name="SEC328"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC327" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC329" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> ifelse </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">IFELSE tf instructionlist1 instructionlist2
</pre></td></tr></table>

<p>command or operation.  If the first input has the value <code>TRUE</code>, then
<code>IFELSE</code> runs the second input.  If the first input has the value <code>FALSE</code>,
then <code>IFELSE</code> runs the third input.  <code>IFELSE</code> outputs a value if the
<var>instructionlist</var> contains an expression that outputs a value.
</p>
<hr size="6">
<a name="TEST"></a>
<a name="SEC329"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC328" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC330" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> test </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">TEST tf
</pre></td></tr></table>

<p>command.  Remembers its input, which must be <code>TRUE</code> or <code>FALSE</code>, for
use by later <code>IFTRUE</code> or <code>IFFALSE</code> instructions.  The effect of
<code>TEST</code> is local to the procedure in which it is used; any corresponding
<code>IFTRUE</code> or <code>IFFALSE</code> must be in the same procedure or a subprocedure.
</p>
<p>See section <a href="#SEC331">iffalse</a> .
</p>
<hr size="6">
<a name="IFTRUE"></a>
<a name="SEC330"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC329" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC331" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> iftrue </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">IFTRUE instructionlist
IFT instructionlist
</pre></td></tr></table>

<p>command.  Runs its input if the most recent <code>TEST</code> instruction had a <code>TRUE</code>
input.  The <code>TEST</code> must have been in the same procedure or a
superprocedure.
</p>
<hr size="6">
<a name="IFFALSE"></a>
<a name="SEC331"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC330" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC332" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> iffalse </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">IFFALSE instructionlist
IFF instructionlist
</pre></td></tr></table>

<p>command.  Runs its input if the most recent <code>TEST</code> instruction had a <code>FALSE</code>
input.  The <code>TEST</code> must have been in the same procedure or a
superprocedure.
</p>
<p>See section <a href="#SEC329">test</a> .
</p>
<hr size="6">
<a name="STOP"></a>
<a name="SEC332"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC331" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC333" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> stop </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">STOP
</pre></td></tr></table>

<p>command.  Ends the running of the procedure in which it appears.
Control is returned to the context in which that procedure was invoked.
The stopped procedure does not output a value.
</p>
<hr size="6">
<a name="OUTPUT"></a>
<a name="SEC333"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC332" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC334" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> output </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">OUTPUT value
OP value
</pre></td></tr></table>

<p>command.  Ends the running of the procedure in which it appears.  That
procedure outputs the value <var>value</var> to the context in which it was
invoked.  Don't be confused: <code>OUTPUT</code> itself is a command, but the
procedure that invokes <code>OUTPUT</code> is an operation.
</p>
<hr size="6">
<a name="CATCH"></a>
<a name="SEC334"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC333" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC335" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> catch </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">CATCH tag instructionlist
</pre></td></tr></table>

<p>command or operation.  Runs its second input.  Outputs if that
<var>instructionlist</var> outputs.  If, while running the instructionlist, a
<code>THROW</code> instruction is executed with a tag equal to the first input
(case-insensitive comparison), then the running of the <var>instructionlist</var> is
terminated immediately.  In this case the <code>CATCH</code> outputs if a value input is
given to <code>THROW</code>.  The <var>tag</var> must be a word.
</p>
<p>If the tag is the word <code>ERROR</code>, then any error condition that arises
during the running of the instructionlist has the effect of <tt>THROW &quot;ERROR</tt>
instead of printing an error message and returning to toplevel.  The
<code>CATCH</code> does not output if an error is caught.  Also, during the running
of the instructionlist, the variable <code>ERRACT</code> is temporarily unbound.  (If
there is an error while <code>ERRACT</code> has a value, that value is taken as an
instructionlist to be run after printing the error message.  Typically
the value of <code>ERRACT</code>, if any, is the list <code>[PAUSE]</code>.)
</p>
<p>See section <a href="#SEC336">error</a> ,
<a href="usermanual_11.html#SEC378">erract</a> ,
<a href="#SEC337">pause</a> .
</p>
<hr size="6">
<a name="THROW"></a>
<a name="SEC335"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC334" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC336" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> throw </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">THROW tag
(THROW tag value)
</pre></td></tr></table>

<p>command.  Must be used within the scope of a <code>CATCH</code> with an equal tag.
Ends the running of the instructionlist of the <code>CATCH</code>.  If <code>THROW</code> is used
with only one input, the corresponding <code>CATCH</code> does not output a value.
If <code>THROW</code> is used with two inputs, the second provides an output for the
<code>CATCH</code>.
</p>
<p><tt>THROW &quot;TOPLEVEL</tt> can be used to terminate all running procedures and
interactive pauses, and return to the toplevel instruction prompt.  Typing the
system interrupt character (&lt;alt-S&gt; for wxWidgets; otherwise normally
&lt;control-C&gt; for Unix, &lt;control-Q&gt; for DOS, or &lt;command-period&gt; for
Mac) has the same effect.
</p>
<p><tt>THROW &quot;ERROR</tt> can be used to generate an error condition.  If the error
is not caught, it prints a message (<code>THROW &quot;ERROR</code>) with the usual
indication of where the error (in this case the <code>THROW</code>) occurred.  If a
second input is used along with a tag of <code>ERROR</code>, that second input is
used as the text of the error message instead of the standard message.
Also, in this case, the location indicated for the error will be, not
the location of the <code>THROW</code>, but the location where the procedure
containing the <code>THROW</code> was invoked.  This allows user-defined procedures
to generate error messages as if they were primitives.  Note: in this
case the corresponding <tt>CATCH &quot;ERROR</tt>, if any, does not output, since the
second input to <code>THROW</code> is not considered a return value.
</p>
<p><tt>THROW &quot;SYSTEM</tt> immediately leaves Logo, returning to the operating
system, without printing the usual parting message and without deleting
any editor temporary file written by EDIT.
</p>
<p>See section <a href="usermanual_7.html#SEC300">edit</a> .
</p>
<hr size="6">
<a name="ERROR"></a>
<a name="SEC336"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC335" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC337" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> error </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">ERROR
</pre></td></tr></table>

<p>outputs a list describing the error just caught, if any.  If there was not an
error caught since the last use of <code>ERROR</code>, the empty list will be
output.  The error list contains four members: an integer code corresponding
to the type of error, the text of the error message (as a single word
including spaces), the name of the procedure in which the error occurred, and
the instruction line on which the error occurred.
</p>
<hr size="6">
<a name="PAUSE"></a>
<a name="SEC337"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC336" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC338" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> pause </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">PAUSE
</pre></td></tr></table>

<p>command or operation.  Enters an interactive pause.  The user is
prompted for instructions, as at toplevel, but with a prompt that
includes the name of the procedure in which <code>PAUSE</code> was invoked.  Local
variables of that procedure are available during the pause.  <code>PAUSE</code>
outputs if the pause is ended by a <code>CONTINUE</code> with an input.
</p>
<p>If the variable <code>ERRACT</code> exists, and an error condition occurs, the
contents of that variable are run as an instructionlist.  Typically
<code>ERRACT</code> is given the value <code>[PAUSE]</code> so that an interactive pause will be
entered in the event of an error.  This allows the user to check values
of local variables at the time of the error.
</p>
<p>Typing the system quit character (&lt;alt-S&gt; for wxWidgets; otherwise
normally &lt;control-\&gt; for Unix, &lt;control-W&gt; for DOS, or
&lt;command-comma&gt; for Mac) will also enter a pause.
</p>
<p>See section <a href="usermanual_11.html#SEC378">erract</a> .
</p>
<hr size="6">
<a name="CONTINUE"></a>
<a name="SEC338"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC337" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC339" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> continue </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">CONTINUE value
CO value
(CONTINUE)
(CO)
</pre></td></tr></table>

<p>command.  Ends the current interactive pause, returning to the context
of the <code>PAUSE</code> invocation that began it.  If <code>CONTINUE</code> is given an input,
that value is used as the output from the <code>PAUSE</code>.  If not, the <code>PAUSE</code> does
not output.
</p>
<p>Exceptionally, the <code>CONTINUE</code> command can be used without its default
input and without parentheses provided that nothing follows it on the
instruction line.
</p>
<hr size="6">
<a name="WAIT"></a>
<a name="SEC339"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC338" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC340" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> wait </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">WAIT time
</pre></td></tr></table>

<p>command.  Delays further execution for <var>time</var> 60ths of a second.  Also
causes any buffered characters destined for the terminal to be printed
immediately.  <tt>WAIT 0</tt> can be used to achieve this buffer flushing without actually waiting.
</p>
<hr size="6">
<a name="BYE"></a>
<a name="SEC340"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC339" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC341" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> bye </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">BYE
</pre></td></tr></table>

<p>command.  Exits from Logo; returns to the operating system.
</p>
<hr size="6">
<a name="dMAYBEOUTPUT"></a>
<a name="SEC341"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC340" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC342" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> .maybeoutput </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">.MAYBEOUTPUT value				(special form)
</pre></td></tr></table>

<p>works like <code>OUTPUT</code> except that the expression that provides the input
value might not, in fact, output a value, in which case the effect is
like <code>STOP</code>.  This is intended for use in control structure definitions,
for cases in which you don't know whether or not some expression
produces a value.  Example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to invoke :function [:inputs] 2
.maybeoutput apply :function :inputs
end

? (invoke &quot;print &quot;a &quot;b &quot;c)
a b c
? print (invoke &quot;word &quot;a &quot;b &quot;c)
abc
</pre></td></tr></table>

<p>This is an alternative to <code>RUNRESULT</code>.  It's fast and easy to use, at the
cost of being an exception to Logo's evaluation rules.  (Ordinarily, it
should be an error if the expression that's supposed to provide an input
to something doesn't have a value.)
</p>
<p>See section <a href="#SEC333">output</a> ,
<a href="#SEC332">stop</a> ,
<a href="#SEC323">runresult</a> .
</p>
<hr size="6">
<a name="GOTO"></a>
<a name="SEC342"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC341" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC343" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> goto </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">GOTO word
</pre></td></tr></table>

<p>command.  Looks for a <code>TAG</code> command with the same input in the same
procedure, and continues running the procedure from the location of that
<code>TAG</code>.  It is meaningless to use <code>GOTO</code> outside of a procedure.
</p>
<hr size="6">
<a name="TAG"></a>
<a name="SEC343"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC342" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC344" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> tag </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">TAG quoted.word
</pre></td></tr></table>

<p>command.  Does nothing.  The input must be a literal word following a
quotation mark (<code>&quot;</code>), not the result of a computation.  Tags are used by
the <code>GOTO</code> command.
</p>
<hr size="6">
<a name="IGNORE"></a>
<a name="SEC344"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC343" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC345" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> ignore </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">IGNORE value					(library procedure)
</pre></td></tr></table>

<p>command.  Does nothing.  Used when an expression is evaluated for a side
effect and its actual value is unimportant.
</p>
<hr size="6">
<a name="back_002dquote"></a>
<a name="SEC345"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC344" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC346" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> ` </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">` list						(library procedure)
</pre></td></tr></table>

<p>outputs a list equal to its input but with certain substitutions.  If a
member of the input list is the word &lsquo;<samp>,</samp>&rsquo; (comma) then the following
member should be an instructionlist that produces an output when run.
That output value replaces the comma and the instructionlist.  If a
member of the input list is the word &lsquo;<samp>,@</samp>&rsquo; (comma atsign) then the
following member should be an instructionlist that outputs a list when
run.  The members of that list replace the &lsquo;<samp>,@</samp>&rsquo; and the instructionlist.
Example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">show `[foo baz ,[bf [a b c]] garply ,@[bf [a b c]]]
</pre></td></tr></table>

<p>will print
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">[foo baz [b c] garply b c]
</pre></td></tr></table>

<p>A word starting with &lsquo;<samp>,</samp>&rsquo; or &lsquo;<samp>,@</samp>&rsquo; is treated as if the rest of the
word were a one-word list, e.g., &lsquo;<samp>,:foo</samp>&rsquo; is equivalent to &lsquo;<samp>,[:Foo]</samp>&rsquo;.
</p>
<p>A word starting with &lsquo;<samp>&quot;,</samp>&rsquo; (quote comma) or &lsquo;<samp>:,</samp>&rsquo; (colon comma)
becomes a word starting with &lsquo;<samp>&quot;</samp>&rsquo; or &lsquo;<samp>:</samp>&rsquo; but with the result of
running the substitution (or its first word, if the result is a list)
replacing what comes after the comma.
</p>
<p>Backquotes can be nested.  Substitution is done only for commas at
the same depth as the backquote in which they are found:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? show `[a `[b ,[1+2] ,[foo ,[1+3] d] e] f]
[a ` [b , [1+2] , [foo 4 d] e] f]

?make &quot;name1 &quot;x
?make &quot;name2 &quot;y
? show `[a `[b ,:,:name1 ,&quot;,:name2 d] e]
[a ` [b , [:x] , [&quot;y] d] e]
</pre></td></tr></table>

<hr size="6">
<a name="FOR"></a>
<a name="SEC346"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC345" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC347" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> for </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">FOR forcontrol instructionlist			(library procedure)
</pre></td></tr></table>

<p>command.  The first input must be a list containing three or four
members: (1) a word, which will be used as the name of a local variable;
(2) a word or list that will be evaluated as by <code>RUN</code> to determine a
number, the starting value of the variable; (3) a word or list that will
be evaluated to determine a number, the limit value of the variable; (4)
an optional word or list that will be evaluated to determine the step
size.  If the fourth member is missing, the step size will be 1 or &ndash;1
depending on whether the limit value is greater than or less than the
starting value, respectively.
</p>
<p>The second input is an instructionlist.  The effect of <code>FOR</code> is to run
that instructionlist repeatedly, assigning a new value to the control
variable (the one named by the first member of the <var>forcontrol</var> list) each
time.  First the starting value is assigned to the control variable.
Then the value is compared to the limit value.  <code>FOR</code> is complete when the
sign of <code>(current - limit)</code> is the same as the sign of the step size.  (If
no explicit step size is provided, the instructionlist is always run at
least once.  An explicit step size can lead to a zero-trip <code>FOR</code>, e.g.,
<tt>FOR [I 1 0 1] ...</tt>). Otherwise, the instructionlist is run, then the step is added to the current value of the control variable and FOR returns to
the comparison step.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? for [i 2 7 1.5] [print :i]
2
3.5
5
6.5
?
</pre></td></tr></table>

<p>See section <a href="#SEC322">run</a> .
</p>
<hr size="6">
<a name="DOdWHILE"></a>
<a name="SEC347"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC346" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC348" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> do.while </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">DO.WHILE instructionlist tfexpression		(library procedure)
</pre></td></tr></table>

<p>command.  Repeatedly evaluates the <var>instructionlist</var> as long as the
evaluated 
remains <code>TRUE</code>.  Evaluates the first input first,
so the <var>instructionlist</var> is always run at least once.  The
<var>tfexpression</var> must be an expressionlist whose value when evaluated is
<code>TRUE</code> or <code>FALSE</code>.
</p>
<hr size="6">
<a name="WHILE"></a>
<a name="SEC348"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC347" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC349" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> while </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">WHILE tfexpression instructionlist		(library procedure)
</pre></td></tr></table>

<p>command.  Repeatedly evaluates the <var>instructionlist</var> as long as the
evaluated
remains <code>TRUE</code>.  Evaluates the first input first,
so the <var>instructionlist</var> may never be run at all.  The <var>tfexpression</var>
must be an expressionlist whose value when evaluated is <code>TRUE</code> or <code>FALSE</code>.
</p>
<hr size="6">
<a name="DOdUNTIL"></a>
<a name="SEC349"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC348" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC350" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> do.until </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">DO.UNTIL instructionlist tfexpression		(library procedure)
</pre></td></tr></table>

<p>command.  Repeatedly evaluates the <var>instructionlist</var> as long as the
evaluated
remains <code>FALSE</code>.  Evaluates the first input
first, so the <var>instructionlist</var> is always run at least once.  The
<var>tfexpression</var> must be an expressionlist whose value when evaluated is
<code>TRUE</code> or <code>FALSE</code>.
</p>
<hr size="6">
<a name="UNTIL"></a>
<a name="SEC350"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC349" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC351" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> until </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">UNTIL tfexpression instructionlist		(library procedure)
</pre></td></tr></table>

<p>command.  Repeatedly evaluates the <var>instructionlist</var> as long as the
evaluated
remains <code>FALSE</code>.  Evaluates the first input
first, so the <var>instructionlist</var> may never be run at all.  The
<var>tfexpression</var> must be an expressionlist whose value when evaluated is
<code>TRUE</code> or <code>FALSE</code>.
</p>
<hr size="6">
<a name="CASE"></a>
<a name="SEC351"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC350" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC352" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> case </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">CASE value clauses					(library procedure)
</pre></td></tr></table>

<p>command or operation.  The second input is a list of lists (clauses);
each clause is a list whose first element is either a list of values
or the word <code>ELSE</code> and whose butfirst is a Logo expression or
instruction.  <code>CASE</code> examines the clauses in order.  If a clause begins
with the word <code>ELSE</code> (upper or lower case), then the butfirst of that
clause is evaluated and <code>CASE</code> outputs its value, if any.  If the first
input to CASE is a member of the first element of a clause, then the
butfirst of that clause is evaluated and <code>CASE</code> outputs its value, if
any.  If neither of these conditions is met, then <code>CASE</code> goes on to the
next clause.  If no clause is satisfied, <code>CASE</code> does nothing.  
Example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to vowelp :letter
output case :letter [ [[a e i o u] &quot;true] [else &quot;false] ]
end
</pre></td></tr></table>

<hr size="6">
<a name="COND"></a>
<a name="SEC352"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC351" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC321" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> cond </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">COND clauses						(library procedure)
</pre></td></tr></table>

<p>command or operation.  The input is a list of lists (clauses); each
clause is a list whose first element is either an expression whose
value is <code>TRUE</code> or <code>FALSE</code>, or the word <code>ELSE</code>, and whose butfirst is a Logo
expression or instruction.  <code>COND</code> examines the clauses in order.  If a
clause begins with the word <code>ELSE</code> (upper or lower case), then the
butfirst of that clause is evaluated and <code>CASE</code> outputs its value, if
any.  Otherwise, the first element of the clause is evaluated; the
resulting value must be <code>TRUE</code> or <code>FALSE</code>.  If it's <code>TRUE</code>, then the
butfirst of that clause is evaluated and <code>COND</code> outputs its value, if
any.  If the value is <code>FALSE</code>, then <code>COND</code> goes on to the next clause.  If
no clause is satisfied, <code>COND</code> does nothing.  Example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to evens :numbers	; select even numbers from a list
op cond [ [[emptyp :numbers] []]
          [[evenp first :numbers]	; assuming EVENP is defined
           fput first :numbers evens butfirst :numbers]
          [else evens butfirst :numbers] ]
end
</pre></td></tr></table>

<hr size="6">
<a name="TEMPLATE_002dBASED-ITERATION"></a>
<a name="SEC353"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC352" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC354" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC320" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 8.2 Template-based Iteration </h2>

<p>The procedures in this section are iteration tools based on the idea of a
<em>template.</em>  This is a generalization of an instruction list or an
expression list in which <em>slots</em> are provided for the tool to insert varying
data.  Four different forms of template can be used.
</p>
<p>The most commonly used form for a template is &lsquo;<samp>explicit-slot</samp>&rsquo; form, or
&lsquo;<samp>question mark</samp>&rsquo; form.  Example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? show map [? * ?] [2 3 4 5]
[4 9 16 25]
?
</pre></td></tr></table>

<p>In this example, the <code>MAP</code> tool evaluated the template <code>[? * ?]</code>
repeatedly, with each of the members of the data list <code>[2 3 4 5]</code>
substituted in turn for the question marks.  The same value was used for every
question mark in a given evaluation.  Some tools allow for more than one datum
to be substituted in parallel; in these cases the slots are indicated by
<code>?1</code> for the first datum, <code>?2</code> for the second, and so on:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? show (map [(word ?1 ?2 ?1)] [a b c] [d e f])
[ada beb cfc]
?
</pre></td></tr></table>

<p>If the template wishes to compute the datum number, the form <code>(? 1)</code> is
equivalent to <code>?1</code>, so <code>(? ?1)</code> means the datum whose number is given in
datum number 1.  Some tools allow additional slot designations, as shown
in the individual descriptions.
</p>
<p>The second form of template is the &lsquo;<samp>named-procedure</samp>&rsquo; form.  If the
template is a word rather than a list, it is taken as the name of a procedure.
That procedure must accept a number of inputs equal to the number of parallel
data slots provided by the tool; the procedure is applied to all of the
available data in order.  That is, if data <code>?1</code> through <code>?3</code> are
available, the template <code>&quot;PROC</code> is equivalent to <tt>[PROC ?1 ?2 ?3]</tt>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? show (map &quot;word [a b c] [d e f])
[ad be cf]
?

to dotprod :a :b	; vector dot product
op apply &quot;sum (map &quot;product :a :b)
end
</pre></td></tr></table>

<p>The third form of template is &lsquo;<samp>named-slot</samp>&rsquo; or &lsquo;<samp>lambda</samp>&rsquo; form.  This
form is indicated by a template list containing more than one member, whose
first member is itself a list.  The first member is taken as a list of names;
local variables are created with those names and given the available data in
order as their values.  The number of names must equal the number of available
data.  This form is needed primarily when one iteration tool must be used
within the template list of another, and the <code>?</code> notation would be ambiguous in
the inner template.  Example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to matmul :m1 :m2 [:tm2 transpose :m2]	; multiply two matrices
output map [[row] map [[col] dotprod :row :col] :tm2] :m1
end
</pre></td></tr></table>

<p>The fourth form is &lsquo;<samp>procedure text</samp>&rsquo; form, a variant of lambda form.  In
this form, the template list contains at least two members, all of which are
lists.  This is the form used by the <code>DEFINE</code> and <code>TEXT</code> primitives,
and <code>APPLY</code> accepts it so that the text of a defined procedure can be
used as a template.
</p>
<p>Note:  The fourth form of template is interpreted differently from the others,
in that Logo considers it to be an independent defined procedure for the
purposes of <code>OUTPUT</code> and <code>STOP</code>.  For example, the following two
instructions are identical:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? print apply [[x] :x+3] [5]
8
? print apply [[x] [output :x+3]] [5]
8
</pre></td></tr></table>

<p>although the first instruction is in named-slot form and the second is in
procedure-text form.  The named-slot form can be understood as telling Logo to
evaluate the expression <tt>:x+3</tt> in place of the entire invocation of
apply, with the variable <code>x</code> temporarily given the value <code>5</code>.  The
procedure-text form can be understood as invoking the procedure
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to foo :x
output :x+3
end
</pre></td></tr></table>

<p>with input <code>5</code>, but without actually giving the procedure a name.  If
the use of <code>OUTPUT</code> were interchanged in these two examples, we'd get errors:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? print apply [[x] output :x+3] [5]
Can only use output inside a procedure
? print apply [[x] [:x+3]] [5]
You don't say what to do with 8
</pre></td></tr></table>

<p>The named-slot form can be used with <code>STOP</code> or <code>OUTPUT</code> inside a procedure,
to stop the enclosing procedure.
</p>
<p>The following iteration tools are extended versions of the ones in Appendix
B of the book <cite>Computer Science Logo Style, Volume 3:  Advanced Topics</cite> by
Brian Harvey [MIT Press, 1987].  The extensions are primarily to allow for
variable numbers of inputs.
</p>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC354">apply</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC355">invoke</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC356">foreach</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC357">map</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                         
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC358">map.se</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      MAP.SE
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC359">filter</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC360">find</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                        
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC361">reduce</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC362">crossmap</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC363">cascade</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC364">cascade.2</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                   CASCADE.2
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC365">transfer</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    
</td></tr>
</table>

<hr size="6">
<a name="APPLY"></a>
<a name="SEC354"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC353" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC355" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> apply </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">APPLY template inputlist
</pre></td></tr></table>

<p>command or operation.  Runs the <var>template</var>, filling its slots with the
members of <var>inputlist.</var>  The number of members in <var>inputlist</var> must be an
acceptable number of slots for <var>template</var>.  It is illegal to apply the
primitive <code>TO</code> as a template, but anything else is okay.  <code>APPLY</code> outputs
what <var>template</var> outputs, if anything.
</p>
<p>See section <a href="usermanual_7.html#SEC233">to</a> .
</p>
<hr size="6">
<a name="INVOKE"></a>
<a name="SEC355"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC354" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC356" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> invoke </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">INVOKE template input				(library procedure)
(INVOKE template input1 input2 ...)
</pre></td></tr></table>

<p>command or operation.  Exactly like <code>APPLY</code> except that the inputs are
provided as separate expressions rather than in a list.
</p>
<hr size="6">
<a name="FOREACH"></a>
<a name="SEC356"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC355" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC357" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> foreach </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">FOREACH data template				(library procedure)
(FOREACH data1 data2 ... template)
</pre></td></tr></table>

<p>command.  Evaluates the <var>template</var> list repeatedly, once for each member
of the <var>data</var> list.  If more than one <var>data</var> list are given, each of them
must be the same length.  (The <var>data</var> inputs can be words, in which case
the template is evaluated once for each character.)
</p>
<p>In a template, the symbol <code>?REST</code> represents the portion of the
<var>data</var> input to the right of the member currently being used as the
<code>?</code> slot-filler.  That is, if the <var>data</var> input is
<code>[A B C D E]</code> and the template is being evaluated with <code>?</code>
replaced by <code>B</code>, then <code>?REST</code> would be replaced by
<code>[C D E]</code>.  If multiple parallel slots are used, then
<tt>(?REST 1)</tt> goes with ?1, etc.
</p>
<p>In a template, the symbol <code>#</code> represents the position in the <var>data</var>
input of the member currently being used as the <code>?</code> slot-filler.  That is, if
the data input is <code>[A B C D E]</code> and the template is being evaluated with
<code>?</code> replaced by <code>B</code>, then <code>#</code> would be replaced by <code>2</code>.
</p>
<hr size="6">
<a name="MAP"></a>
<a name="SEC357"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC356" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC358" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> map </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">MAP template data				(library procedure)
(MAP template data1 data2 ...)
</pre></td></tr></table>

<p>outputs a word or list, depending on the type of the <var>data</var> input, of the
same length as that <var>data</var> input.  (If more than one <var>data</var> input are
given, the output is of the same type as <var>data1</var>.)  Each member of the
output is the result of evaluating the <var>template</var> list, filling the slots
with the corresponding member(s) of the <var>data</var> input(s).  (All <var>data</var>
inputs must be the same length.)  In the case of a word output, the results of
the template evaluation must be words, and they are concatenated with
<code>WORD</code>.
</p>
<p>In a template, the symbol <code>?REST</code> represents the portion of the data
input to the right of the member currently being used as the <code>?</code>
slot-filler.  That is, if the <var>data</var> input is <code>[A B C D E]</code> and
the <var>template</var> is being evaluated with <code>?</code> replaced by <code>B</code>, then
<code>?REST</code> would be replaced by <code>[C D E]</code>. If multiple parallel
slots are used, then <tt>(?REST 1)</tt> goes with <code>?1</code>, etc.
</p>
<p>In a template, the symbol <code>#</code> represents the position in the <var>data</var>
input of the member currently being used as the <code>?</code> slot-filler.  That
is, if the data input is <code>[A B C D E]</code> and the template is being
evaluated with <code>?</code> replaced by <code>B</code>, then <code>#</code> would be replaced
by <code>2</code>.
</p>
<p>See section <a href="usermanual_2.html#SEC8">word</a> .
</p>
<hr size="6">
<a name="MAPdSE"></a>
<a name="SEC358"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC357" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC359" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> map.se </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">MAP.SE template data				(library procedure)
(MAP.SE template data1 data2 ...)
</pre></td></tr></table>

<p>outputs a list formed by evaluating the <var>template</var> list repeatedly and
concatenating the results using <code>SENTENCE</code>.  That is, the members of the
output are the members of the results of the evaluations.  The output
list might, therefore, be of a different length from that of the <var>data</var>
input(s).  (If the result of an evaluation is the empty list, it
contributes nothing to the final output.)  The <var>data</var> inputs may be words
or lists.
</p>
<p>In a template, the symbol <code>?REST</code> represents the portion of the data
input to the right of the member currently being used as the <code>?</code>
slot-filler.  That is, if the data input is <code>[A B C D E]</code> and the
template is being evaluated with <code>?</code> replaced by <code>B</code>, then
<code>?REST</code> would be replaced by <code>[C D E]</code>. If multiple parallel
slots are used, then <tt>(?REST 1)</tt> goes with <code>?1</code>, etc.
</p>
<p>In a template, the symbol <code>#</code> represents the position in the <var>data</var>
input of the member currently being used as the <code>?</code> slot-filler.  That
is, if the data input is <code>[A B C D E]</code> and the template is being
evaluated with <code>?</code> replaced by <code>B</code>, then <code>#</code> would be replaced
by <code>2</code>.
</p>
<p>See section <a href="usermanual_2.html#SEC10">sentence</a> .
</p>
<hr size="6">
<a name="FILTER"></a>
<a name="SEC359"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC358" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC360" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> filter </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">FILTER tftemplate data				(library procedure)
</pre></td></tr></table>

<p>outputs a word or list, depending on the type of the <var>data</var> input,
containing a subset of the members (for a list) or characters (for a
word) of the input.  The template is evaluated once for each member or
character of the data, and it must produce a <code>TRUE</code> or <code>FALSE</code> value.  If
the value is <code>TRUE</code>, then the corresponding input constituent is included
in the output.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? print filter &quot;vowelp &quot;elephant 
eea 
?
</pre></td></tr></table>

<p>In a template, the symbol <code>?REST</code> represents the portion of the
<var>data</var> input to the right of the member currently being used as the
<code>?</code> slot-filler.  That is, if the data input is <code>[A B C D E]</code>
and the template is being evaluated with <code>?</code> replaced by <code>B</code>, then
<code>?REST</code> would be replaced by <code>[C D E]</code>.
</p>
<p>In a template, the symbol <code>#</code> represents the position in the <var>data</var>
input of the member currently being used as the <code>?</code> slot-filler.  That
is, if the data input is <code>[A B C D E]</code> and the template is being
evaluated with <code>?</code> replaced by <code>B</code>, then <code>#</code> would be replaced
by <code>2</code>.
</p>
<hr size="6">
<a name="FIND"></a>
<a name="SEC360"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC359" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC361" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> find </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">FIND tftemplate data				(library procedure)
</pre></td></tr></table>

<p>outputs the first constituent of the <var>data</var> input (the first member of a
list, or the first character of a word) for which the value produced by
evaluating the <var>template</var> with that consituent in its slot is <code>TRUE</code>.
If there is no such constituent, the empty list is output.
</p>
<p>In a template, the symbol <code>?REST</code> represents the portion of the
<var>data</var> input to the right of the member currently being used as the
<code>?</code> slot-filler.  That is, if the data input is <code>[A B C D E]</code>
and the template is being evaluated with <code>?</code> replaced by <code>B</code>, then
<code>?REST</code> would be replaced by <code>[C D E]</code>.
</p>
<p>In a template, the symbol <code>#</code> represents the position in the <var>data</var>
input of the member currently being used as the <code>?</code> slot-filler.  That
is, if the data input is <code>[A B C D E]</code> and the template is being
evaluated with <code>?</code> replaced by <code>B</code>, then <code>#</code> would be replaced
by <code>2</code>.
</p>
<hr size="6">
<a name="REDUCE"></a>
<a name="SEC361"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC360" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC362" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> reduce </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">REDUCE template data				(library procedure)
</pre></td></tr></table>

<p>outputs the result of applying the <var>template</var> to accumulate the members of
the <var>data</var> input.  The template must be a two-slot function.  Typically it
is an associative function name like <code>SUM</code>.  If the <var>data</var> input has
only one constituent (member in a list or character in a word), the output is
that consituent.  Otherwise, the template is first applied with <code>?1</code>
filled with the next-to-last consitient and <code>?2</code> with the last
constituent.  Then, if there are more constituents, the template is applied
with <code>?1</code> filled with the next constituent to the left and <code>?2</code> with
the result from the previous evaluation.  This process continues until all
constituents have been used.  The data input may not be empty.
</p>
<p>Note: If the template is, like <code>SUM</code>, the name of a procedure that is
capable of accepting arbitrarily many inputs, it is more efficient to
use <code>APPLY</code> instead of <code>REDUCE</code>.  The latter is good for associative
procedures that have been written to accept exactly two inputs:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to max :a :b
output ifelse :a &gt; :b [:a] [:b]
end

print reduce &quot;max [...]
</pre></td></tr></table>

<p>Alternatively, <code>REDUCE</code> can be used to write <code>MAX</code> as a procedure
that accepts any number of inputs, as <code>SUM</code> does:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to max [:inputs] 2
if emptyp :inputs ~
   [(throw &quot;error [not enough inputs to max])]
output reduce [ifelse ?1 &gt; ?2 [?1] [?2]] :inputs
end
</pre></td></tr></table>

<p>See section <a href="usermanual_4.html#SEC116">sum</a> ,
<a href="#SEC354">apply</a> .
</p>
<hr size="6">
<a name="CROSSMAP"></a>
<a name="SEC362"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC361" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC363" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> crossmap </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">CROSSMAP template listlist			(library procedure)
(CROSSMAP template data1 data2 ...)
</pre></td></tr></table>

<p>outputs a list containing the results of template evaluations.  Each
<var>data</var> list contributes to a slot in the template; the number of slots is
equal to the number of <var>data</var> list inputs.  As a special case, if only one
<var>data</var> list input is given, that list is taken as a list of data lists,
and each of its members contributes values to a slot.  <code>CROSSMAP</code> differs
from <code>MAP</code> in that instead of taking members from the data inputs in
parallel, it takes all possible combinations of members of data inputs,
which need not be the same length.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? show (crossmap [word ?1 ?2] [a b c] [1 2 3 4])
[a1 a2 a3 a4 b1 b2 b3 b4 c1 c2 c3 c4]
?
</pre></td></tr></table>

<p>For compatibility with the version in the first edition of CSLS
<a name="DOCF1" href="usermanual_fot.html#FOOT1">(1)</a>, <code>CROSSMAP</code> templates may
use the notation <code>:1</code> instead of <code>?1</code> to indicate slots.
</p>
<p>See section <a href="#SEC357">map</a> .
</p>
<hr size="6">
<a name="CASCADE"></a>
<a name="SEC363"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC362" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC364" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> cascade </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">CASCADE endtest template startvalue		(library procedure)
(CASCADE endtest tmp1 sv1 tmp2 sv2 ...)
(CASCADE endtest tmp1 sv1 tmp2 sv2 ... finaltemplate)
</pre></td></tr></table>

<p>outputs the result of applying a template (or several templates, as
explained below) repeatedly, with a given value filling the slot the
first time, and the result of each application filling the slot for the
following application.
</p>
<p>In the simplest case, <code>CASCADE</code> has three inputs.  The second input is a
one-slot expression template.  That template is evaluated some number of
times (perhaps zero).  On the first evaluation, the slot is filled with
the third input; on subsequent evaluations, the slot is filled with the
result of the previous evaluation.  The number of evaluations is
determined by the first input.  This can be either a nonnegative
integer, in which case the template is evaluated that many times, or a
predicate expression template, in which case it is evaluated (with the
same slot filler that will be used for the evaluation of the second
input) repeatedly, and the <code>CASCADE</code> evaluation continues as long as the
predicate value is <code>FALSE</code>.  (In other words, the predicate template
indicates the condition for stopping.)
</p>
<p>If the template is evaluated zero times, the output from <code>CASCADE</code> is the
third (<var>startvalue</var>) input.  Otherwise, the output is the value produced
by the last template evaluation.
</p>
<p><code>CASCADE</code> templates may include the symbol <code>#</code> to represent the
number of times the template has been evaluated.  This slot is filled with 1
for the first evaluation, 2 for the second, and so on.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">? show cascade 5 [lput # ?] []
[1 2 3 4 5]
? show cascade [vowelp first ?] [bf ?] &quot;spring
ing
? show cascade 5 [# * ?] 1
120
?
</pre></td></tr></table>

<p>Several cascaded results can be computed in parallel by providing additional
template-startvalue pairs as inputs to <code>CASCADE</code>.  In this case, all
templates (including the endtest template, if used) are multi-slot, with the
number of slots equal to the number of pairs of inputs.  In each round of
evaluations, <code>?2</code>, for example, represents the result of evaluating the
second template in the previous round.  If the total number of inputs
(including the first endtest input) is odd, then the output from CASCADE is
the final value of the first template.  If the total number of inputs is even,
then the last input is a template that is evaluated once, after the end test
is satisfied, to determine the output from <code>CASCADE</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">to fibonacci :n
output (cascade :n [?1 + ?2] 1 [?1] 0)
end

to piglatin :word
output (cascade [vowelp first ?] ~
                [word bf ? first ?] ~
                :word ~
                [word ? &quot;ay])
end
</pre></td></tr></table>

<hr size="6">
<a name="CASCADEd2"></a>
<a name="SEC364"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC363" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC365" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> cascade.2 </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">CASCADE.2 endtest temp1 startval1 temp2 startval2  (library procedure)
</pre></td></tr></table>

<p>outputs the result of invoking <code>CASCADE</code> with the same inputs.  The only
difference is that the default number of inputs is five instead of three.
</p>
<hr size="6">
<a name="TRANSFER"></a>
<a name="SEC365"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC364" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC353" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="unnumberedsubsec"> transfer </h3>

<table><tr><td>&nbsp;</td><td><pre class="example">TRANSFER endtest template inbasket		(library procedure)
</pre></td></tr></table>

<p>outputs the result of repeated evaluation of the <var>template</var>.  The template
is evaluated once for each member of the list <var>inbasket</var>.  <code>TRANSFER</code>
maintains an <em>outbasket</em> that is initially the empty list.  After each
evaluation of the template, the resulting value becomes the new
outbasket.
</p>
<p>In the template, the symbol <code>?IN</code> represents the current member from the
inbasket; the symbol <code>?OUT</code> represents the entire current outbasket.
Other slot symbols should not be used.
</p>
<p>If the first (<var>endtest</var>) input is an empty list, evaluation continues
until all inbasket members have been used.  If not, the first input must
be a predicate expression template, and evaluation continues until
either that template's value is <code>TRUE</code> or the inbasket is used up.
</p>


<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC320" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="usermanual_9.html#SEC366" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="usermanual.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_13.html#SEC391" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="usermanual_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>Brian Harvey</em> on <em>September, 3 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
 </font>
 <br>

</p>
</body>
</html>