cond:   what it should have been
cond/  strict
7.1

cond: what it should have been

This module provides cond/strict, a version of cond that raises an error when all the clause conditions return false, instead of returning #<void>.

syntax

(cond/strict cond-clause ...)

 
cond-clause = [test-expr then-body ...+]
  | [else then-body ...+]
  | [test-expr => proc-expr]
  | [test-expr]
Exactly like cond, except for one thing:

If there is no else clause and every test-expr returns false, cond/strict raises an error instead of returning #<void>.

Examples:
> (require cond-strict)
> (cond/strict
    [else 5])

5

> (cond/strict
    [#false 42]
    [else 5])

5

> (cond/strict
    [#false 42])

cond: all clause conditions were false

> (cond/strict
    [(positive? -5) (error "doesn't get here")]
    [(zero? -5) (error "doesn't get here, either")]
    [(positive? 5) 'here])

'here

> (cond/strict
    [(member 2 '(1 2 3)) => (lambda (l) (map - l))])

'(-2 -3)

> (cond/strict
    [(member 2 '(1 2 3))])

'(2 3)

> (cond/strict
    [(member 9.75 '(1 2 3)) 42])

cond: all clause conditions were false