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

and


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

Syntax

(and [expr1 ... ])
exprN - an expression
returns - NIL if any expression evaluates to NIL , otherwise the value of the last expression
Note: evaluation of expressions stops after the first expression that evaluates to NIL

Description

The 'and' special form evaluates a sequence of expressions and returns the effect of a logical AND on the expressions. If, at any point, an expression is NIL, NIL is returned as the result of the 'and' function. If all of the expressions have a non-NIL value, the value of the last expression is returned as the result. Evaluation of the expressions will stop when an expression evaluates to NIL, none of the subsequent expressions will be evaluated. If there are no expressions, 'and' returns  T  as its result.

Examples

(and T "boo" "hiss" T "rah")          ; returns "rah"
(and T T T T)                         ; returns T
(and)                                 ; returns T
(and (princ "hi") NIL (princ "ho"))   ; prints  hi and returns NIL
(and (princ "hi") (princ " de ")      ; prints  hi de ho
                  (princ "ho"))       ;   returns "ho"
(setq a 5)   (setq b 6)               ; set up A and B
(if (and (numberp a)                  ; if      A is a number
         (numberp b)                  ;     and B is a number
         (< a b) )                    ;     and A<B
  (print "A is less than B")          ;   THEN do this
  (print "something else happened"))  ;   ELSE do this
                                      ; prints "A is less than B"

See the and special form in the XLISP 2.0 manual.

  Back to Top


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