Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

mapc

mapc

type: function (subr) 
location: built-in
source file: xllist.c
Common LISP compatible: yes
supported on: all machines

SYNTAX

(mapc <function> <list1> [ <list2> ... ] )
        <function>      -       a function definition (like a LAMBDA) 
                                or a function name
        <listN>         -       a list or list expression

DESCRIPTION

MAPC applies the <function> to the succesive CARs of each of the lists <listN>. Each of the lists supplies one of the arguments to <function>. The MAPC 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

(mapc 'princ '(hi there bob))           ; prints HITHEREBOB
                                        ;   returns (HI THERE BOB)
                                        ;
(mapc '+ '(1 2 3) '(1 2 3))             ; returns (1 2 3)
                                        ;   there were no side effects
                                        ;
(mapc (lambda (x y) (print (+ x y)))    ; define fun. with side effects
      '(1 2 3) '(1 2 3))                ;   prints 2 4 6 
                                        ;   returns (1 2 3)

NOTE: The use of the <function> will work properly when it is a quoted symbol (which is the name of the function), an unquoted symbol (whose value is a function) or a closure object (like a LAMBDA).


Go to the first, previous, next, last section, table of contents.