If it is true, do it; otherwise, do something else.
This function lets you test two conditions: if test is true, then perform statement1, else perform statement2. (Statement2 is optional.) If test is true, then LISP returns the value of statement1. If test is not true, then LISP returns the value of statement2.
Examples
Code | Returns |
---|---|
(setq d 9) | |
(if (>= d 10) "Greater") | nil |
(if (>= d 8) "Greater") | "Greater" |
(if (and (> d 12) (< d 13)) "In range" "Out of range") | "Out of range" |
NOTE The if function only allows a single statement for statement1 and statement2. If you want a multi-line statement, surround them by the progn function, as in the following example:
Tell me about...
(cond (statement1 result1 ...) ...)
(repeat number statement1 [statement2 ...])
(setq symbol1 statement1 [symbol2 statement2] ...)
Programming Overview of LISP (LISt Processing) Language
Bricscad™ is commercialized by Bricsys NV. Bricsys NV and Vondle NV are fully owned subsidiaries of Menhirs NV. © 2001- Menhirs NV - All rights reserved. |