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

length


Type:   -   function (subr)
Source:   -   xllist.c

Syntax

(length expr)
expr - a list expression or string expression
returns - the length of the list, array or string

Description

The 'length' function returns the length of the 'expr'. If the 'expr' is a string, the number of characters is returned. If the 'expr' is a list, the number of top level elements [atoms or sublists] is returned. If the list is NIL , a '0' is returned.

Examples

(length NIL)                     ; returns 0
(length 'a)                      ; error: bad argument type
(length '(a))                    ; returns 1
(length '(1 2 3 4 5 6))          ; returns 6
(length '(a (b c) (d (e) f) g))  ; returns 4
(length "12345")                 ; returns 5

See the length function in the XLISP 2.0 manual.

  Back to Top


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