Exercise 4.3.1: (back)
Question: Decide which of the following two cond-expressions is legal:
(cond (cond
[(< n 10) 20] [(< n 10) 20]
[(> n 20) 0] [(and (> n 20) (<= n 30))]
[else 1]) [else 1])
Answer: The cond-expression on the left is legal.
The cond-expression on the right contains a clause with a question but with no
answer.
Question: Why is the following illegal?
(cond [(< n 10) 20]
[* 10 n]
[else 555]) ;
Answer: Firstly, the clause [* 10 n] contains three expressions, instead of two. Secondly
the clause must contain a question and answer which must equate to either true or
false.