(case statement (clause1) (clause2)...) -> #f, or varies
(case statement (clause1) (clause2)... (else clause)) -> varies
Evaluates statement. Then, from left to right, compares each item in the lists of data that begin each clause. If (eq? key datum) would return true, then the expressions following within that clause are evaluated. The result of the last expression evaluated is returned as the result.
If the else clause is given, and no true result for eq? can be found in any other clause, the expression(s) following else are evaluated, and the last expressions evaluated has its result returned.
If no true comparison is found and there is no else clause, then #f is returned.
Note that the R5RS standard for Scheme, from which this derives, requires that they match in the sense of eqv?. In MOSVM, eq? is used.
Examples:
>> (case 1 ((1 2 3) "It's a number!") (("a" "b" "c") "It's a letter!")) :: "It's a number!"
>> (case "Ringo" (("John" "Paul" "George" "Ringo") "Who's the Walrus?") (("Davy" "Micky" "Mike" "Peter") "We're too busy singing!")) :: #f
This returns unspecified because of the Non-Schemish behavior of case. (eq? "Ringo" "Ringo") returns #f, and so no match could be found.
Had we used an else clause:
>> (case "Ringo" (("John" "Paul" "George" "Ringo") "Who's the Walrus?") (("Davy" "Micky" "Mike" "Peter") "We're too busy singing!") (else "Some other band."))
:: "Some other band."
>>