CONDITION and BRANCH Functions


CONDITION FUNCTIONS

(= <atom1>.......<atomn>)

Returns a T if all <atoms> are numerically equal. (= a b c d)


(/= <atom1> < atom2>)

Returns a T if <atom1> is not equal to <atom2> (/= 2 1) T


(< <atom1>......<atomn>)

Less than. Each atom must be less than the atom to the right. (< 6 5 4 3) T


(<= <atom1>......<atomn>)

Less than or equal to. Each atom must be less than or equal to the atom to the right. (<= 6 5 4 6) T


(> <atom1>......<atomn>)

Greater than. Each atom must be greater than the atom to the right. (> 2 3 4 5) T


(>= <atom1>......<atomn>)

Greater than or equal to. Each atom must be greater than or equal to the atom to the right. (>= 2 3 4 4) T


(AND <expr1>.....<exprn>)

Logical And. Returns T if all expressions are not nil. (and (< 2 3) (> 4 3)) T


(OR <expr1>.....<exprn>)

Logical OR. Returns T if any expression is not nil. (or (< 2 5) (> 8 9)) T


(NOT <expr>)

Logical Not. Returns T if the expression evaluates to nil. (not (= 2 3)) T



BRANCH FUNTIONS

(IF <test-expr> <then-expr> [<else-expr>])

Evaluates then-expr if test-expr is true. If not, then the else-expr is evaluated. (if (< 2 3) (print "true") (print "false")) true


(COND (<test1> <expr1.....exprn>) (<test2> <expr1.....exprn>) (T nil) )

Each test expression is evaluated sequentially until one is found that is not-nil. It then evaluates those expressions that follow the test. Any number of test expressions are possible. It is common to use T as the final test expression as an error-check in case all other tests fail. (cond ((= 2 3) (print "true")) ((= 2 4) (print "true")) ((= 2 2) (print "true")) (T nil) ) true


(progn <expr1>....<exprn>)

Evaluates each expression in order and returns the value of the last expression. This is used with IF and COND to force multiple expressions to be evaluated. (progn (setq a 2) (setq b 4) ) 4





Example functions page
Back Home