939:, a switch statement consists of two nodes (entrance and exit), plus one edge between them for each option. By contrast, a sequence of "if...else if...else if" statements has an additional node for every case other than the first and last, together with a corresponding edge. The resulting control-flow graph for the sequences of "if"s thus has many more nodes and almost twice as many edges, with these not adding any useful information. However, the simple branches in the if statements are individually conceptually easier than the complex branch of a switch statement. In terms of
36:
595:
compilers supported a SWITCH data type which contains a list of "designational expressions". A GOTO statement could reference a switch variable and, by providing an index, branch to the desired destination. With experience it was realized that a more formal multi-way construct, with single point of
861:
through the values in the cases. A branch table allows the switch statement to determine with a small, constant number of instructions which branch to execute without having to go through a list of comparisons, while a binary search takes only a logarithmic number of comparisons, measured in the
783:
statement. This is thus seen by many as a language wart, and warned against in some lint tools. Syntactically, the cases are interpreted as labels, not blocks, and the switch and break statements explicitly change control flow. Some languages influenced by C, such as
1233:
blocks at runtime, allowing a number of less obvious uses for the construction. This prohibits certain compiler optimizations, so is more common in dynamic and scripting languages where the enhanced flexibility is more important than the performance overhead.
731:
The second form are unstructured switches, as in C, where the cases are treated as labels within a single block, and the switch functions as a generalized goto. This distinction is referred to as the treatment of fallthrough, which is elaborated below.
681:
the corresponding sequence of statements. The value (or list/range of values) is usually separated from the corresponding statement sequence by a colon or by an implication arrow. In many languages, every case must also be preceded by a keyword such as
2089:(that may be implemented as a simple lookup table) can also be customized to accommodate multiple conditions on multiple inputs if required and usually exhibits greater 'visual compactness' than an equivalent switch (that can occupy many statements).
557:
Kleene provides a proof of this in terms of the
Boolean-like recursive functions "sign-of" sg( ) and "not sign of" ~sg( ) (Kleene 1952:222-223); the first returns 1 if its input is positive and −1 if its input is negative.
657:
clause containing a boolean expression and a match occurs for the first case for which that expression evaluates to true. This usage is similar to the if/then/elseif/else structures in some other languages, e.g.,
1957:, where if an exception is raised in a block, a separate branch is chosen, depending on the exception. In some cases a default branch, if no exception is raised, is also present. An early example is
724:
The first form are structured switches, as in Pascal, where exactly one branch is taken, and the cases are treated as separate, exclusive blocks. This functions as a generalized if–then–else
779:
keyword at the end of the matching body, which exits execution of the switch block, but this can cause bugs due to unintentional fallthrough if the programmer forgets to insert the
1379:
This feature is also useful for checking multiple variables against one value rather than one variable against many values. COBOL also supports this form (and other forms) in the
230:
Switch statements come in two main variants: a structured switch, as in Pascal, which takes exactly one branch, and an unstructured switch, as in C, which functions as a type of
2070:
statements since many languages can optimize table lookups, whereas switch statements are not optimized unless the range of values is small with few gaps. A non-optimized, non-
771:
case in the source text. This also allows multiple values to match the same point without any special syntax: they are just listed with empty bodies. Values can be
767:, instead feature fallthrough, where control moves to the matching case, and then execution continues ("falls through") to the statements associated with the
788:, retain default fallthrough, while others remove fallthrough, or only allow it in special circumstances. Notable variations on this in the C-family include
924:. For example, deciding program flow based on a single character's value, if correctly implemented, is vastly more efficient than the alternative, reducing
677:
Each alternative begins with the particular value, or list of values (see below), that the control variable may match and which will cause the control to
909:
Fixed depth: a sequence of "if else if" statements may yield deep nesting, making compilation more difficult (especially in automatically generated code)
772:
756:
dialects influenced by Pascal, most functional languages, and many others. To allow multiple values to execute the same code (and avoid needing to
1246:, a constant can be used as the "variable" to check against, and the first case statement which evaluates to that constant will be executed:
966:, 19 March 2019, as a preview feature. Here a whole switch expression can be used to return a value. There is also a new form of case label,
970:
where the right-hand-side is a single expression. This also prevents fall through and requires that cases are exhaustive. In Java SE 13 the
740:
In many languages, only the matching block is executed, and then execution continues at the end of the switch statement. These include the
705:
keyword. This executes when none of the other cases match the control expression. In some languages, such as C, if no case matches and the
616:
In most languages, programmers write a switch statement across many individual lines using one or two keywords. A typical syntax involves:
2034:(In some languages, only actual data types are allowed as values in the lookup table. In other languages, it is also possible to assign
2229:
635:
subsequent lines defining the actual cases (the values), with corresponding sequences of statements for execution when a match occurs
760:), Pascal-type languages permit any number of values per case, given as a comma-separated list, as a range, or as a combination.
100:
900:
Easier to debug (e.g. setting breakpoints on code vs. a call table, if the debugger has no conditional breakpoint capability)
72:
673:
clause containing a boolean expression and a match occurs for the first case for which that expression evaluates to true.
79:
2183:
2158:
725:
234:. The main reasons for using a switch include improving clarity, by reducing otherwise repetitive coding, and (if the
2512:
2487:
2263:
119:
53:
865:
Normally, the only method of finding out if this optimization has occurred is by actually looking at the resultant
86:
2528:
974:
statement is introduced, and in Java SE 14 switch expressions become a standard language feature. For example:
920:
implementation may execute much faster than the alternative, because it is often implemented by using an indexed
917:
912:
Easier to verify that all values are handled. Compilers can issue a warning if some enum values are not handled.
842:
17:
2216:
2074:
lookup, however, will almost certainly be slower than either a non-optimized switch or the equivalent multiple
789:
208:
196:
164:
57:
569:. They too offer a proof of the primitive recursiveness of this function (Boolos-Burgess-Jeffrey 2002:74-75).
1974:
741:
180:
133:
68:
653:, the control expression is optional; if there is no control expression then each alternative begins with a
1978:
414:
2242:
2035:
1841:# Unlike conditions in if statements, the `or` keyword cannot be used here to differentiate between cases
1740:
1404:
204:
172:
2049:
184:
963:
2004:
that examine the target one value at a time. Fallthrough behavior can be achieved with a sequence of
2001:
188:
156:
925:
858:
846:
566:
46:
413:
formally proved that the CASE function (the IF-THEN-ELSE function being its simplest form) is a
2109:
2096:
1457:
Ruby also returns a value that can be assigned to a variable, and doesn’t actually require the
561:
Boolos-Burgess-Jeffrey make the additional observation that "definition by cases" must be both
176:
141:
93:
940:
239:
2064:
588:
531:) shall have the value given by the first clause which applies) is primitive recursive in φ
800:
unless the block is empty (i.e. fallthrough is used as a way to specify multiple values).
8:
811:
keyword. This prevents unintentional fallthrough but allows it when desired. Similarly,
2052:
does not support case/switch statements. This lookup technique is one way to implement
1954:
1755:
keywords. Unlike other languages, Python notably doesn't exhibit fallthrough behavior.
936:
573:
562:
2508:
2483:
2259:
2212:
2179:
2154:
1982:
1538:
866:
812:
200:
168:
763:
Languages derived from C language, and more generally those influenced by
Fortran's
2405:
2377:
2124:
2092:
831:
2500:
2496:
928:
considerably. When implemented as such, a switch statement essentially becomes a
775:
with code in the case body. In practice, fallthrough is usually prevented with a
608:
introduced forms of this construct which have survived through modern languages.
2475:
2352:
757:
410:
2522:
2492:
2129:
2119:
2086:
2071:
2043:
764:
417:, where he defines the notion "definition by cases" in the following manner:
2114:
2016:
1387:
statement where the control expression is omitted altogether and the first
929:
921:
870:
854:
145:
807:
does not fall through by default, but a case may explicitly do so using a
713:
statement simply does nothing. In others, like PL/I, an error is raised.
577:
238:
permit) also offering the potential for faster execution through easier
2460:
785:
669:, no control expression is allowed and each alternative begins with a
140:
is a type of selection control mechanism used to allow the value of a
235:
27:
Type of selection control mechanism in computer programming languages
2434:
2409:
2381:
2327:
2303:
2279:
35:
1958:
803:
In some cases languages provide optional fallthrough. For example,
693:
An optional default case is typically also allowed, specified by a
605:
1411:
equality, the statement can be used to test for variable’s class:
2410:"PEP 635 – Structural Pattern Matching: Motivation and Rationale"
892:
749:
601:
584:
2095:, which is used to implement switch-like functionality in many
2038:
as lookup table values, gaining the same flexibility as a real
830:
An example of a switch statement that relies on fallthrough is
1953:
A number of languages implement a form of switch statement in
624:, followed by an expression which is often referred to as the
889:
statement is considered superior to an equivalent series of
881:
In some languages and programming environments, the use of a
850:
753:
744:
family (Object Pascal, Modula, Oberon, Ada, etc.) as well as
721:
Semantically, there are two main forms of switch statements.
592:
192:
160:
804:
745:
678:
666:
659:
650:
597:
231:
2063:
In some cases, lookup tables are more efficient than non-
1243:
906:
Easier to understand, and consequently easier to maintain
1796:# first non-whitespace character of the input, lowercase
1916:# `case _` is equivalent to `default` from C and others
2382:"PEP 634 – Structural Pattern Matching: Specification"
2056:
statements in the Lua language, which has no built-in
576:: its usage replaces both primitive recursion and the
815:
defaults to not falling through when terminated with
151:
Switch statements function somewhat similarly to the
60:. Unsourced material may be challenged and removed.
2482:, North-Holland Publishing Company, Amsterdam NL,
728:, here with any number of branches, not just two.
596:entrance and exit, was needed. Languages such as
207:, and in many other types of language, using such
2435:"PEP 636 – Structural Pattern Matching: Tutorial"
1591:; No cases match or "default" code here
2520:
2375:
873:output that has been generated by the compiler.
792:, in which all blocks must be terminated with a
1993:Some alternatives to switch statements can be:
1383:statement. PL/I has an alternative form of the
876:
2404:
2304:"JEP 354: Switch Expressions (Second Preview)"
1461:to have any parameters (acting a bit like an
853:may compile a switch statement into either a
155:statement used in programming languages like
2507:, Cambridge University Press, Cambridge UK,
2176:"Effective Java: Programming Language Guide"
2350:
1229:Many languages evaluate expressions inside
638:In languages with fallthrough behaviour, a
2253:
2243:From Switch Statement Down to Machine Code
2211:, p. 38. Prentice Hall, Eaglewood Cliffs.
2023:values and, as values, the part under the
591:statement for multi-way branching. Early
862:number of cases in the switch statement.
523:are mutually exclusive predicates (or φ(x
148:of program execution via search and map.
120:Learn how and when to remove this message
385:"You're not 1, 2, 3 or 4!"
2505:Computability and Logic: Fourth Edition
2280:"JEP 325: Switch Expressions (Preview)"
943:, both of these options increase it by
14:
2521:
2456:
2454:
2198:"Definition by cases", Kleene 1952:229
1973:defines a case. This is also found in
2173:
2148:
1948:
954:
572:The IF-THEN-ELSE is the basis of the
361:"You're three or four."
247:An example of a Switch statement in C
2209:Expert C Programming: Deep C Secrets
2167:
2142:
1772:"Put in a single letter: "
58:adding citations to reliable sources
29:
2451:
2432:
2254:Guntheroth, Kurt (April 27, 2016).
1743:634-636 were accepted, which added
1224:
24:
2469:
2408:; van Rossum, Guido (2020-09-12).
2178:(third ed.). Addison-Wesley.
465:. . . . . . . . . . . .
25:
2540:
2046:article for more detail on this).
1723:; Equivalent to "break"
1657:; Equivalent to "break"
646:statement to end said statement.
611:
421:"#F. The function φ defined thus
34:
2480:Introduction to Metamathematics
2426:
2398:
2369:
2344:
2320:
2258:. O'Reilly Media. p. 182.
2019:, which contains, as keys, the
1988:
1750:
1744:
967:
407:Introduction to Metamathematics
244:
45:needs additional citations for
2296:
2272:
2247:
2235:
2222:
2207:van der Linden, Peter (1994).
2201:
2192:
2008:conditionals each without the
837:
819:, but allows fallthrough with
735:
642:statement typically follows a
134:computer programming languages
13:
1:
2328:"JEP 361: Switch Expressions"
2135:
340:"You're three."
175:and exist in most high-level
2478:, 1952 (10th reprint 1991),
2439:Python Enhancement Proposals
2414:Python Enhancement Proposals
2386:Python Enhancement Proposals
2149:Skeet, Jon (23 March 2019).
1532:
1434:'input is an Array!'
877:Advantages and disadvantages
716:
415:primitive recursive function
144:or expression to change the
7:
2357:Python 3.10.6 documentation
2353:"What's New In Python 3.10"
2103:
903:Easier for a person to read
313:"You're two."
286:"You're one."
10:
2545:
1449:'input is a Hash!'
896:statements because it is:
400:
2515:paperback. cf page 74-75.
1734:
1407:, due to its handling of
665:In some languages, e.g.,
649:In some languages, e.g.,
2351:Galindo Salgado, Pablo.
1757:
1543:
1467:
1413:
1248:
976:
926:instruction path lengths
587:compilers supported the
253:
2461:Switch statement in Lua
1398:
632:of the switch statement
567:collectively exhaustive
2529:Conditional constructs
2174:Bloch, Joshua (2018).
2110:Algorithmic efficiency
1537:A switch statement in
1237:
555:
177:imperative programming
1940:is not a vowel!"
1901:may be a vowel."
941:cyclomatic complexity
419:
240:compiler optimization
843:Optimizing compilers
54:improve this article
2433:Moisset, Daniel F.
2232:, released in 2009.
1969:syntax, where each
1739:For Python 3.10.6,
773:special conditioned
249:
1955:exception handling
1949:Exception handling
1391:that evaluates to
962:are introduced in
960:Switch expressions
955:Switch expressions
937:control-flow graph
748:, modern forms of
626:control expression
574:McCarthy formalism
563:mutually exclusive
245:
179:languages such as
69:"Switch statement"
2378:van Rossum, Guido
1983:Visual Basic .NET
1865:is a vowel!"
1539:assembly language
916:Additionally, an
405:In his 1952 text
398:
397:
201:Visual Basic .NET
169:Visual Basic .NET
130:
129:
122:
104:
16:(Redirected from
2536:
2463:
2458:
2449:
2448:
2446:
2445:
2430:
2424:
2423:
2421:
2420:
2402:
2396:
2395:
2393:
2392:
2376:Bucher, Brandt;
2373:
2367:
2366:
2364:
2363:
2348:
2342:
2341:
2339:
2338:
2332:openjdk.java.net
2324:
2318:
2317:
2315:
2314:
2308:openjdk.java.net
2300:
2294:
2293:
2291:
2290:
2284:openjdk.java.net
2276:
2270:
2269:
2251:
2245:
2241:Vlad Lazarenko.
2239:
2233:
2226:
2220:
2205:
2199:
2196:
2190:
2189:
2171:
2165:
2164:
2146:
2093:Pattern matching
2069:
2059:
2055:
2041:
2026:
2022:
1972:
1968:
1964:
1961:, which use the
1944:
1941:
1938:
1935:
1932:
1929:
1926:
1923:
1920:
1917:
1914:
1911:
1908:
1905:
1902:
1899:
1896:
1893:
1890:
1887:
1884:
1881:
1878:
1875:
1872:
1869:
1866:
1863:
1860:
1857:
1854:
1851:
1848:
1845:
1842:
1839:
1836:
1833:
1830:
1827:
1824:
1821:
1818:
1815:
1812:
1809:
1806:
1803:
1800:
1797:
1794:
1791:
1788:
1785:
1782:
1779:
1776:
1773:
1770:
1767:
1764:
1761:
1754:
1753:
1748:
1747:
1730:
1727:
1724:
1721:
1718:
1715:
1712:
1709:
1706:
1703:
1700:
1697:
1694:
1691:
1688:
1685:
1682:
1679:
1676:
1673:
1670:
1667:
1664:
1661:
1658:
1655:
1652:
1649:
1646:
1643:
1640:
1637:
1634:
1631:
1628:
1625:
1622:
1619:
1616:
1613:
1610:
1607:
1604:
1601:
1598:
1595:
1592:
1589:
1586:
1583:
1580:
1577:
1574:
1571:
1568:
1565:
1562:
1559:
1556:
1553:
1550:
1547:
1528:
1525:
1522:
1519:
1516:
1513:
1510:
1507:
1504:
1501:
1498:
1495:
1492:
1489:
1486:
1483:
1480:
1477:
1474:
1471:
1464:
1460:
1453:
1450:
1447:
1444:
1441:
1438:
1435:
1432:
1429:
1426:
1423:
1420:
1417:
1410:
1390:
1386:
1382:
1375:
1372:
1369:
1366:
1363:
1360:
1357:
1354:
1351:
1348:
1345:
1342:
1339:
1336:
1333:
1330:
1327:
1324:
1321:
1318:
1315:
1312:
1309:
1306:
1303:
1300:
1297:
1294:
1291:
1288:
1285:
1282:
1279:
1276:
1273:
1270:
1267:
1264:
1261:
1258:
1255:
1252:
1242:For example, in
1232:
1225:Alternative uses
1220:
1217:
1214:
1211:
1208:
1205:
1202:
1199:
1196:
1193:
1190:
1187:
1184:
1181:
1178:
1175:
1172:
1169:
1166:
1163:
1160:
1157:
1154:
1151:
1148:
1145:
1142:
1139:
1136:
1133:
1130:
1127:
1124:
1121:
1118:
1115:
1112:
1109:
1106:
1103:
1100:
1097:
1094:
1091:
1088:
1085:
1082:
1079:
1076:
1073:
1070:
1067:
1064:
1061:
1058:
1055:
1052:
1049:
1046:
1043:
1040:
1037:
1034:
1031:
1028:
1025:
1022:
1019:
1016:
1013:
1010:
1007:
1004:
1001:
998:
995:
992:
989:
986:
983:
980:
973:
969:
935:In terms of the
888:
884:
826:
822:
818:
810:
799:
795:
782:
778:
712:
708:
704:
700:
696:
689:
685:
672:
656:
645:
641:
630:control variable
623:
553:
552:Stephen Kleene,
392:
389:
386:
383:
380:
377:
374:
371:
368:
365:
362:
359:
356:
353:
350:
347:
344:
341:
338:
335:
332:
329:
326:
323:
320:
317:
314:
311:
308:
305:
302:
299:
296:
293:
290:
287:
284:
281:
278:
275:
272:
269:
266:
263:
260:
257:
250:
226:
222:
218:
214:
154:
138:switch statement
125:
118:
114:
111:
105:
103:
62:
38:
30:
21:
2544:
2543:
2539:
2538:
2537:
2535:
2534:
2533:
2519:
2518:
2501:Richard Jeffrey
2472:
2470:Further reading
2467:
2466:
2459:
2452:
2443:
2441:
2431:
2427:
2418:
2416:
2403:
2399:
2390:
2388:
2374:
2370:
2361:
2359:
2349:
2345:
2336:
2334:
2326:
2325:
2321:
2312:
2310:
2302:
2301:
2297:
2288:
2286:
2278:
2277:
2273:
2266:
2252:
2248:
2240:
2236:
2227:
2223:
2206:
2202:
2197:
2193:
2186:
2172:
2168:
2161:
2147:
2143:
2138:
2106:
2067:
2057:
2053:
2042:statement. See
2039:
2024:
2020:
1991:
1970:
1966:
1962:
1951:
1946:
1945:
1942:
1939:
1936:
1933:
1930:
1927:
1924:
1921:
1918:
1915:
1912:
1909:
1906:
1903:
1900:
1897:
1894:
1891:
1888:
1885:
1882:
1879:
1876:
1873:
1870:
1867:
1864:
1861:
1858:
1855:
1852:
1849:
1846:
1843:
1840:
1837:
1834:
1831:
1828:
1825:
1822:
1819:
1816:
1813:
1810:
1807:
1804:
1801:
1798:
1795:
1792:
1789:
1786:
1783:
1780:
1777:
1774:
1771:
1768:
1765:
1762:
1759:
1751:
1745:
1737:
1732:
1731:
1728:
1725:
1722:
1719:
1716:
1713:
1710:
1707:
1704:
1701:
1698:
1695:
1692:
1689:
1686:
1683:
1680:
1677:
1674:
1671:
1668:
1665:
1662:
1659:
1656:
1653:
1650:
1647:
1644:
1641:
1638:
1635:
1632:
1629:
1626:
1623:
1620:
1617:
1614:
1611:
1608:
1605:
1602:
1599:
1596:
1593:
1590:
1587:
1584:
1581:
1578:
1575:
1572:
1569:
1566:
1563:
1560:
1557:
1554:
1551:
1548:
1545:
1535:
1530:
1529:
1526:
1523:
1520:
1517:
1514:
1511:
1508:
1505:
1502:
1499:
1496:
1493:
1490:
1487:
1484:
1481:
1478:
1475:
1472:
1469:
1462:
1458:
1455:
1454:
1451:
1448:
1445:
1442:
1439:
1436:
1433:
1430:
1427:
1424:
1421:
1418:
1415:
1408:
1401:
1388:
1384:
1380:
1377:
1376:
1373:
1370:
1367:
1364:
1361:
1358:
1355:
1352:
1349:
1346:
1343:
1340:
1337:
1334:
1331:
1328:
1325:
1322:
1319:
1316:
1313:
1311:'howdy'
1310:
1307:
1304:
1301:
1298:
1295:
1292:
1289:
1286:
1283:
1280:
1278:'hello'
1277:
1274:
1271:
1268:
1265:
1262:
1259:
1256:
1253:
1250:
1240:
1230:
1227:
1222:
1221:
1218:
1215:
1212:
1209:
1206:
1203:
1200:
1197:
1194:
1191:
1188:
1185:
1182:
1179:
1176:
1173:
1170:
1167:
1164:
1161:
1158:
1155:
1152:
1149:
1146:
1143:
1140:
1137:
1134:
1131:
1128:
1125:
1122:
1119:
1116:
1113:
1110:
1107:
1104:
1101:
1098:
1095:
1092:
1089:
1086:
1083:
1080:
1077:
1074:
1071:
1068:
1065:
1062:
1059:
1056:
1053:
1050:
1047:
1044:
1041:
1038:
1035:
1032:
1029:
1026:
1023:
1020:
1017:
1014:
1011:
1008:
1005:
1002:
999:
996:
993:
990:
987:
984:
981:
978:
971:
957:
886:
882:
879:
840:
824:
820:
816:
808:
797:
793:
780:
776:
738:
719:
710:
709:is omitted the
706:
702:
698:
694:
687:
683:
670:
654:
643:
639:
621:
614:
554:
551:
546:
542:
538:
534:
530:
526:
522:
518:
506:
502:
498:
491:
487:
483:
479:
475:
471:
461:
457:
453:
449:
445:
441:
432:
428:
403:
394:
393:
390:
387:
384:
381:
378:
375:
372:
369:
366:
363:
360:
357:
354:
351:
348:
345:
342:
339:
336:
333:
330:
327:
324:
321:
318:
315:
312:
309:
306:
303:
300:
297:
294:
291:
288:
285:
282:
279:
276:
273:
270:
267:
264:
261:
258:
255:
242:in many cases.
224:
220:
216:
212:
152:
126:
115:
109:
106:
63:
61:
51:
39:
28:
23:
22:
18:Decode (Oracle)
15:
12:
11:
5:
2542:
2532:
2531:
2517:
2516:
2490:
2476:Stephen Kleene
2471:
2468:
2465:
2464:
2450:
2425:
2397:
2380:(2020-09-12).
2368:
2343:
2319:
2295:
2271:
2264:
2246:
2234:
2221:
2200:
2191:
2185:978-0134685991
2184:
2166:
2160:978-1617294532
2159:
2140:
2139:
2137:
2134:
2133:
2132:
2127:
2122:
2117:
2112:
2105:
2102:
2101:
2100:
2090:
2082:
2081:
2080:
2079:
2061:
2047:
2029:
2028:
2013:
1990:
1987:
1950:
1947:
1758:
1736:
1733:
1544:
1534:
1531:
1468:
1414:
1400:
1397:
1249:
1239:
1236:
1226:
1223:
977:
956:
953:
914:
913:
910:
907:
904:
901:
878:
875:
839:
836:
758:duplicate code
737:
734:
718:
715:
675:
674:
663:
647:
636:
633:
613:
612:Typical syntax
610:
549:
544:
540:
536:
532:
528:
524:
520:
516:
513:
512:
511:
510:
509:
508:
504:
500:
496:
493:
489:
485:
481:
477:
473:
469:
466:
463:
459:
455:
451:
447:
443:
439:
430:
426:
411:Stephen Kleene
402:
399:
396:
395:
254:
128:
127:
42:
40:
33:
26:
9:
6:
4:
3:
2:
2541:
2530:
2527:
2526:
2524:
2514:
2513:0-521-00758-5
2510:
2506:
2502:
2498:
2494:
2493:George Boolos
2491:
2489:
2488:0-7204-2103-9
2485:
2481:
2477:
2474:
2473:
2462:
2457:
2455:
2440:
2436:
2429:
2415:
2411:
2407:
2401:
2387:
2383:
2379:
2372:
2358:
2354:
2347:
2333:
2329:
2323:
2309:
2305:
2299:
2285:
2281:
2275:
2267:
2265:9781491922033
2261:
2257:
2256:Optimized C++
2250:
2244:
2238:
2231:
2225:
2218:
2214:
2210:
2204:
2195:
2187:
2181:
2177:
2170:
2162:
2156:
2152:
2145:
2141:
2131:
2130:Index mapping
2128:
2126:
2125:Duff's device
2123:
2121:
2120:Control table
2118:
2116:
2113:
2111:
2108:
2107:
2098:
2094:
2091:
2088:
2087:control table
2084:
2083:
2077:
2073:
2072:binary search
2066:
2062:
2051:
2048:
2045:
2044:Control table
2037:
2033:
2032:
2031:
2030:
2018:
2014:
2011:
2007:
2003:
2000:
1996:
1995:
1994:
1986:
1984:
1980:
1976:
1960:
1956:
1928:"Letter
1889:"Letter
1853:"Letter
1756:
1742:
1542:
1540:
1466:
1412:
1406:
1396:
1395:is executed.
1394:
1247:
1245:
1235:
975:
965:
961:
952:
950:
946:
942:
938:
933:
931:
927:
923:
919:
911:
908:
905:
902:
899:
898:
897:
895:
894:
874:
872:
868:
863:
860:
859:binary search
856:
852:
848:
844:
835:
833:
832:Duff's device
828:
814:
806:
801:
791:
787:
774:
770:
766:
765:computed GOTO
761:
759:
755:
751:
747:
743:
733:
729:
727:
722:
714:
691:
680:
668:
664:
661:
652:
648:
637:
634:
631:
627:
619:
618:
617:
609:
607:
603:
599:
594:
590:
589:computed GOTO
586:
583:The earliest
581:
579:
575:
570:
568:
564:
559:
548:
494:
467:
464:
437:
436:
435:
434:
424:
423:
422:
418:
416:
412:
408:
252:
251:
248:
243:
241:
237:
233:
228:
210:
206:
202:
198:
194:
190:
186:
182:
178:
174:
170:
166:
162:
158:
149:
147:
143:
139:
135:
124:
121:
113:
102:
99:
95:
92:
88:
85:
81:
78:
74:
71: –
70:
66:
65:Find sources:
59:
55:
49:
48:
43:This article
41:
37:
32:
31:
19:
2504:
2497:John Burgess
2479:
2442:. Retrieved
2438:
2428:
2417:. Retrieved
2413:
2406:Kohn, Tobias
2400:
2389:. Retrieved
2385:
2371:
2360:. Retrieved
2356:
2346:
2335:. Retrieved
2331:
2322:
2311:. Retrieved
2307:
2298:
2287:. Retrieved
2283:
2274:
2255:
2249:
2237:
2224:
2208:
2203:
2194:
2175:
2169:
2150:
2144:
2115:Branch table
2075:
2017:lookup table
2009:
2005:
2002:conditionals
1998:
1997:A series of
1992:
1989:Alternatives
1952:
1738:
1536:
1465:statement):
1456:
1402:
1392:
1378:
1241:
1228:
959:
958:
948:
947:−1 if given
944:
934:
930:perfect hash
922:branch table
915:
890:
880:
871:machine code
864:
855:branch table
841:
829:
802:
768:
762:
739:
730:
723:
720:
692:
676:
629:
625:
615:
582:
571:
560:
556:
514:
507:) otherwise,
420:
406:
404:
246:
229:
150:
146:control flow
137:
131:
116:
107:
97:
90:
83:
76:
64:
52:Please help
47:verification
44:
2230:version 4.0
2153:. Manning.
2151:C# in Depth
2078:statements.
1874:'y'
1835:'u'
1829:'o'
1823:'i'
1817:'e'
1811:'a'
1678:'b'
1612:'a'
968:case L->
838:Compilation
736:Fallthrough
726:conditional
578:mu-operator
2444:2022-08-19
2419:2022-08-19
2391:2022-08-19
2362:2022-08-19
2337:2021-04-28
2313:2021-04-28
2289:2021-04-28
2217:0131774298
2136:References
2099:languages.
2097:functional
2027:statement.
964:Java SE 12
786:JavaScript
620:the first
236:heuristics
110:April 2013
80:newspapers
2065:optimized
2036:functions
1533:Assembler
918:optimized
827:instead.
717:Semantics
699:otherwise
527:, ... , x
519:, ... , Q
503:, ... , x
488:, ... , x
476:, ... , x
458:, ... , x
446:, ... , x
429:, ... , x
2523:Category
2503:, 2002,
2104:See also
1959:Modula-3
1790:casefold
1381:EVALUATE
867:assembly
845:such as
809:continue
606:ALGOL-68
550:—
543:, ..., Q
535:, ..., φ
209:keywords
142:variable
2076:if-else
2012:clause.
1999:if-else
1729:swtend:
1546:switch:
1470:catfood
1463:else if
951:cases.
893:else if
825:;;&
750:Fortran
707:default
695:default
602:ALGOL-W
585:Fortran
515:where Q
401:History
373:default
225:inspect
94:scholar
2511:
2499:, and
2486:
2262:
2228:since
2215:
2182:
2157:
2068:switch
2058:switch
2054:switch
2040:switch
1981:, and
1975:Delphi
1971:EXCEPT
1967:EXCEPT
1934:letter
1895:letter
1859:letter
1802:letter
1760:letter
1735:Python
1720:swtend
1654:swtend
1588:swtend
1524:normal
1518:senior
1497:junior
1385:SELECT
1329:switch
1251:switch
1231:switch
988:switch
887:switch
821:;&
798:return
742:Pascal
711:switch
622:select
604:, and
480:) if Q
450:) if Q
379:printf
355:printf
334:printf
307:printf
280:printf
256:switch
221:select
213:switch
181:Pascal
96:
89:
82:
75:
67:
1979:Scala
1919:print
1880:print
1844:print
1799:match
1781:strip
1766:input
1746:match
1491:<=
1425:Array
1419:input
1368:break
1353:break
1320:break
1293:break
1207:yield
1195:yield
1159:yield
1123:yield
1093:->
1078:->
1045:->
994:month
982:ndays
972:yield
857:or a
851:Clang
794:break
781:break
777:break
754:BASIC
701:, or
640:break
593:ALGOL
367:break
319:break
292:break
101:JSTOR
87:books
2509:ISBN
2484:ISBN
2260:ISBN
2213:ISBN
2180:ISBN
2155:ISBN
2025:case
2021:case
2010:else
1907:case
1871:case
1808:case
1752:case
1749:and
1741:PEPs
1663:push
1597:push
1521:else
1512:>
1500:when
1479:when
1476:case
1459:case
1446:puts
1443:then
1440:Hash
1437:when
1431:puts
1428:then
1422:when
1416:case
1405:Ruby
1399:Ruby
1393:true
1389:WHEN
1359:case
1344:case
1299:case
1266:case
1257:true
1204:else
1177:year
1168:else
1141:year
1132:else
1105:year
1087:case
1054:case
1003:case
883:case
813:Bash
805:Perl
769:next
752:and
746:PL/I
703:else
688:when
684:case
679:goto
671:WHEN
667:Rexx
660:Perl
655:WHEN
651:PL/I
644:case
598:BCPL
565:and
433:) =
346:case
325:case
298:case
271:case
232:goto
217:case
205:Java
173:Java
136:, a
73:news
2050:Lua
1965:...
1963:TRY
1726:...
1717:jmp
1711:pop
1708:10h
1705:int
1702:00h
1693:mov
1690:0Eh
1681:mov
1669:mov
1651:jmp
1645:pop
1642:10h
1639:int
1636:00h
1627:mov
1624:0Eh
1615:mov
1603:mov
1585:jmp
1576:01h
1567:cmp
1558:00h
1549:cmp
1527:end
1509:age
1503:cat
1488:age
1482:cat
1452:end
1409:===
1403:In
1362:$ y
1347:$ x
1305:$ z
1290:();
1287:foo
1272:$ x
1244:PHP
1238:PHP
1147:100
1111:400
1090:FEB
1075:NOV
1069:SEP
1063:JUN
1057:APR
1042:DEC
1036:OCT
1030:AUG
1024:JUL
1018:MAY
1012:MAR
1006:JAN
979:int
891:if
885:or
869:or
849:or
847:GCC
823:or
796:or
686:or
628:or
545:m+1
539:, Q
537:m+1
497:m+1
425:φ(x
262:age
223:or
211:as
193:C++
185:Ada
161:C++
132:In
56:by
2525::
2495:,
2453:^
2437:.
2412:.
2384:.
2355:.
2330:.
2306:.
2282:.
2085:A
2015:A
2006:if
1985:.
1977:,
1793:()
1784:()
1714:ah
1696:bh
1684:ah
1672:al
1666:ah
1660:b:
1648:ah
1630:bh
1618:ah
1606:al
1600:ah
1594:a:
1579:je
1570:ah
1561:je
1552:ah
1541::
1515:10
1308:==
1275:==
1219:};
1210:28
1198:29
1186:==
1171:if
1162:28
1150:==
1135:if
1126:29
1114:==
1099:if
1081:30
1048:31
932:.
834:.
817:;;
790:C#
697:,
690:.
600:,
580:.
499:(x
492:),
484:(x
472:(x
462:),
454:(x
442:(x
409:,
388:);
364:);
343:);
316:);
289:);
227:.
219:,
215:,
203:,
199:,
197:C#
195:,
187:,
183:,
171:,
167:,
165:C#
163:,
153:if
2447:.
2422:.
2394:.
2365:.
2340:.
2316:.
2292:.
2268:.
2219:.
2188:.
2163:.
2060:.
1943:)
1937:}
1931:{
1925:f
1922:(
1913::
1910:_
1904:)
1898:}
1892:{
1886:f
1883:(
1877::
1868:)
1862:}
1856:{
1850:f
1847:(
1838::
1832:|
1826:|
1820:|
1814:|
1805::
1787:.
1778:.
1775:)
1769:(
1763:=
1699:,
1687:,
1675:,
1633:,
1621:,
1609:,
1582:b
1573:,
1564:a
1555:,
1506:.
1494:1
1485:.
1473:=
1374:}
1371:;
1365::
1356:;
1350::
1341:{
1338:)
1335:5
1332:(
1326:}
1323:;
1317::
1314:)
1302:(
1296:;
1284::
1281:)
1269:(
1263:{
1260:)
1254:(
1216:}
1213:;
1201:;
1192:)
1189:0
1183:4
1180:%
1174:(
1165:;
1156:)
1153:0
1144:%
1138:(
1129:;
1120:)
1117:0
1108:%
1102:(
1096:{
1084:;
1072:,
1066:,
1060:,
1051:;
1039:,
1033:,
1027:,
1021:,
1015:,
1009:,
1000:{
997:)
991:(
985:=
949:k
945:k
662:.
547:.
541:1
533:1
529:n
525:1
521:m
517:1
505:n
501:1
495:φ
490:n
486:1
482:m
478:n
474:1
470:m
468:φ
460:n
456:1
452:1
448:n
444:1
440:1
438:φ
431:n
427:1
391:}
382:(
376::
370:;
358:(
352::
349:4
337:(
331::
328:3
322:;
310:(
304::
301:2
295:;
283:(
277::
274:1
268:{
265:)
259:(
191:/
189:C
159:/
157:C
123:)
117:(
112:)
108:(
98:·
91:·
84:·
77:·
50:.
20:)
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.