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

listp


Type:   -   predicate function (subr)
Source:   -   xlbfun.c

Syntax

(listp expr)
expr - the expression to check
returns -  T  if the value is a list or NIL , NIL otherwise

Description

The 'listp' predicate function checks if the 'expr' is a list.  T  is returned if 'expr' is a list or an empty list [the NIL value], NIL is returned otherwise.

Examples

(listp '(a b))                  ; returns T - list
(listp nil)                     ; returns T - NIL
(listp '(a . b))                ; returns T - dotted pair list

(listp (lambda (x) (print x)))  ; returns NIL - closure - lambda
(listp #(1 2 3))                ; returns NIL - array
(listp *standard-output*)       ; returns NIL - stream
(listp 1.2)                     ; returns NIL - float
(listp #'quote)                 ; returns NIL - fsubr
(listp 1)                       ; returns NIL - integer
(listp object)                  ; returns NIL - object
(listp "str")                   ; returns NIL - string
(listp #'car)                   ; returns NIL - subr
(listp 'a)                      ; returns NIL - symbol

Note: NIL or '() is used in many places as a list-class or atom-class expression. Both atom and 'listp', when applied to NIL , return  T . If you wish to check for a non-empty list, use the consp predicate function.

See the listp function in the XLISP 2.0 manual.

  Back to Top


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