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

mapl


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

Syntax

(mapl function list1 [list2 ... ])
function - a function definition like a lambda form or a function name
listN - a list or list expression
returns - a list that is equivalent to list1

Description

Tha 'mapl' 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 'mapl' function returns a list that is equivalent to the first list 'list1'. It's purpose is to perform operations that have side-effects. If the lists are of different lengths, the shortest list will determine the number of applications of 'function'.

Examples

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

;; apply a lambda function to a list
(mapl (lambda (x y) (princ x) (princ y) (terpri))
      '(a b c) '(1 2 3))     ; prints (A B C)(1 2 3)
                             ;        (B C)(2 3)
                             ;        (C)(3)
                             ; returns (A B C)

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 mapl function in the XLISP 2.0 manual.

  Back to Top


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