chickadee » ck-macros » c-if

(c-if TEST PASS FAIL) → PASS or FAILsyntax

Conditional branching. If TEST is '#f, this yields FAIL. Otherwise it yields PASS.

Due to the way the CK machine works, both branches will be expanded, then the unneeded branch will be discarded. If you only want the needed branch to be expanded (e.g. because the branches are complex and slow to expand, or because it would be an error to expand the unneeded branch), use c-if* instead.

Analogous to (lambda (test pass fail) (if test pass fail)).

(ck () (c-quote (c-if (c-pair? '(x))
                      'pair
                      'not-pair)))
;; ==> 'pair

(ck () (c-quote (c-if (c-pair? 'x)
                      'pair
                      'not-pair)))
;; ==> 'not-pair