File: case.html

package info (click to toggle)
drscheme 1%3A352-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 71,608 kB
  • ctags: 55,284
  • sloc: ansic: 278,966; cpp: 63,318; sh: 32,265; lisp: 14,530; asm: 7,327; makefile: 4,846; pascal: 4,363; perl: 2,920; java: 1,632; yacc: 755; lex: 258; sed: 93; xml: 12
file content (1 line) | stat: -rw-r--r-- 1,826 bytes parent folder | download
1
<html><head><title>case</title><h1>case</h1></head><body><ul><li><code class="scheme">(<code class="scheme"><span class="keyword">case</span></code> <b>EXPRESSION</b> ((<b>CHOICE</b> <b>CHOICE</b> ...) <b>EXPRESSION</b>) ((<b>CHOICE</b> <b>CHOICE</b> ...) <b>EXPRESSION</b>) ...)</code><br /> A <code class="scheme"><span class="keyword">case</span></code> form contains an expression and one or more branches, or "lines". Each line contains a sequence of choices --- numbers and names for symbols --- and an answer expression. The initial expression is evaluated, and the resulting value is compared to the choices in each line, where the lines are considered in order. To evaluate a line, first check whether the value is one of the choices. If so, then the result of the whole <code class="scheme"><span class="keyword">case</span></code> is the result of evaluating the answer expression of the line. If the value is not one of the choices, the line is discarded and evaluation proceeds with the next line. If none of the lines contains a matching choice, it is an error. </li><li><code class="scheme">(<code class="scheme"><span class="keyword">case</span></code> <b>EXPRESSION</b> ((<b>CHOICE</b> <b>CHOICE</b> ...) <b>EXPRESSION</b>) ... (<code class="scheme"><span class="keyword">else</span></code> <b>EXPRESSION</b>))</code><br /> This form of <code class="scheme"><span class="keyword">case</span></code> is similar to the prior one except that the final <code class="scheme"><span class="keyword">else</span></code> clause is always taken if no prior line's choices match. In other words, there is no possibility that evaluation will "fall off the end" of the <code class="scheme"><span class="keyword">case</span></code> expression. </li></ul><p><a href="index.htm">Advanced Student Language</a></p></body></html>