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

nth


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

Syntax

(nth expr list-expr)
expr - an integer expression
list-expr - a list or list expression
returns - the nth element or NIL if the list isn't that long

Description

'nth' returns the 'expr'-th element of 'list-expr'. If the 'list-expr' is shorter than 'expr', a NIL is returned. The counting sequence is base zero, the first element is the 0th element.

Examples

(nth 4 '(0 1 2 3 4 5 6))  ; returns 4
(nth 3 '(a b))            ; returns NIL

(nth 4 'a)                ; error: bad argument type
(nth 3 "abcdefg")         ; error: bad argument type

See the nth function in the XLISP 2.0 manual.

  Back to Top


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