《通链参考手册》


Special Operator IF

●语法设定:

if test-form then-form [else-form] => result*

●参数和值:

Test-form---a form.

Then-form---a form.

Else-form---a form. The default is nil.

results---if the test-form yielded true, the values returned by the then-form; otherwise, the values returned by the else-form.

●详情:

if allows the execution of a form to be dependent on a single test-form.

First test-form is evaluated. If the result is true, then then-form is selected; otherwise else-form is selected. Whichever form is selected is then evaluated.

●例子:

 (if t 1) =>  1
 (if nil 1 2) =>  2 
 (defun test ()
   (dolist (truth-value '(t nil 1 (a b c)))
     (if truth-value (print 'true) (print 'false))
     (prin1 truth-value))) =>  TEST
 (test)
>>  TRUE T
>>  FALSE NIL
>>  TRUE 1
>>  TRUE (A B C)
=>  NIL

●受制于: 无。

●例外情况: 无。

●更多信息:

cond, unless, when

●说明:

 (if test-form then-form else-form)
 ==  (cond (test-form then-form) (t else-form))


◇首页 § ◎章节目录 § □内容索引 § ○符号索引 § △术语表 § ※设计草案