XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

if


Type:   -   special form (fsubr)
Source:   -   xlcont.c

Syntax

(if test-expr then-expr [else-expr])
test-expr - an expression
then-expr - the THEN clause, an expression
else-expr - the ELSE clause, an optional expression
returns - the value of the selected expression

Description

The 'if' special form evaluates the 'test-expr'. If 'test-expr' evaluates to a non-NIL value, then 'then-expr' is evaluated and returned as the result. If 'test-expr' evaluates to NIL and there is an 'else-expr', then the 'else-expr' is evaluated and its result is returned. If there is no 'else-expr' and 'test-expr' evaluates to NIL , then NIL is returned as a result.

Examples

(if T (print "will print")     ; prints  "will print"
      (print "won't print"))

(if NIL (print "won't print")
        (print "will print"))  ; prints  "will print"

(if 'a T NIL)                  ; returns T

(if NIL 'nope 'yep)            ; returns YEP

See the  if  special form in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next