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

maplist


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

Syntax

(maplist function list1 [list2 ... ])
function - a function definition like a lambda or a function name
listN - a list or list expression
returns - a list that is constructed from the results of the function applications

Description

The 'maplist' function applies the 'function' to the successive cdrs of each of the lists 'listN'. Each of the lists supplies one of the arguments to 'function'. The 'maplist' function returns a list that is constructed from the results of the 'function' applications. If the lists are of different lengths, the shortest list will determine the number of applications of 'function'.

Examples

(maplist 'print '(a b c))      ; prints (A B C)
                               ;        (B C)
                               ;        (C)
                               ; returns ((A B C) (B C) (C))

;; append the lists into one list and find it's length
(maplist (lambda (x y) (length (append x y)))
         '(a b c d) '(1 2 3 4))  ; returns (8 6 4 2)

Note: The use of the 'function' will work properly when it is a quoted symbol [the name of the function], an unquoted symbol whose value is a function or a closure object like a lambda form.

See the maplist function in the XLISP 2.0 manual.

  Back to Top


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