User Tools

Site Tools


ch2_1_cond

This is an old revision of the document!


COND

COND is a multi branched conditional in LISP and accepts any number arguments, that must be lists - clauses. Sequentially, first element of the list is evaluated. If the result is NIL the rest of the clause is ignored. If the first element is true (not NIL), the following items in the clause are evaled as in PROGN and the result of the last is returned from the COND.

>(setq a 2)                    ; prepare A for this example
2
 
>(cond ((= a 1) (print "beep") 1)
       ((= a 2) (print "beep") (print "beep") 2)
       ((= a 3) (print "beep") (print "beep") (print "beep") 3)
       (T "none")) 
"beep"
"beep"
2       
ch2_1_cond.1645629617.txt.gz · Last modified: 2022/02/23 08:20 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki