From: Hyunchul Kim
Subject: re: # of argument of mapcar
Date: 
Message-ID: <Pine.SOL.3.96L.990216171719.3126I-100000@unix11.andrew.cmu.edu>
Hi,

I am looking at a  book and  it says that mapcar  can take two arguments
(eg., two lists) but when I tried it in Common Lisp, it only took one
argument.

What is the way around this limit in Common Lisp; is there another
function for this purpose or do I need to use some help-function together
with mapcar?

Thanks.
 - Jay

From: Rainer Joswig
Subject: Re: # of argument of mapcar
Date: 
Message-ID: <joswig-1602992349200001@194.163.195.67>
In article <········································@unix11.andrew.cmu.edu>, Hyunchul Kim <········@andrew.cmu.edu> wrote:

> Hi,
> 
> I am looking at a  book and  it says that mapcar  can take two arguments
> (eg., two lists) but when I tried it in Common Lisp, it only took one
> argument.
> 
> What is the way around this limit in Common Lisp; is there another
> function for this purpose or do I need to use some help-function together
> with mapcar?
> 
> Thanks.
>  - Jay

MAPCAR function list &rest more-lists
[Function]
applies function to the car of list and more-lists, then to the cadr,
and so on. The results are collected into a list, which is returned. If the
lists are not all the same length, the iteration terminates when the
shortest list runs out. function can be only of type symbol or function.

Or see:

http://www.harlequin.com/education/books/HyperSpec/Body/fun_mapccm_ma_istcm_mapcon.html

-- 
http://www.lavielle.com/~joswig
From: Pierre Mai
Subject: Re: # of argument of mapcar
Date: 
Message-ID: <87aeyddfq0.fsf@orion.dent.isdn.cs.tu-berlin.de>
Hyunchul Kim <········@andrew.cmu.edu> writes:

> I am looking at a  book and  it says that mapcar  can take two arguments
> (eg., two lists) but when I tried it in Common Lisp, it only took one
> argument.

The function you supply to mapcar must accept as many arguments, as
you supply lists to map over, since mapcar maps over all supplied
lists in parallel.

E.g.:

(mapcar #'cons '(1 2 3 4) '(a b c d))

(mapcar #'+ '(1 2 3 4) '(10 20 30 40) '(100 200 300 400))

Regs, Pierre.

-- 
Pierre Mai <····@acm.org>               http://home.pages.de/~trillian/
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]
From: SLong
Subject: Re: # of argument of mapcar
Date: 
Message-ID: <36DB3C02.33AE@isomedia.com>
Hyunchul Kim wrote:
> 
> Hi,
> 
> I am looking at a  book and  it says that mapcar  can take two arguments
> (eg., two lists) but when I tried it in Common Lisp, it only took one
> argument.
> 
> What is the way around this limit in Common Lisp; is there another
> function for this purpose or do I need to use some help-function together
> with mapcar?
> 
> Thanks.
>  - Jay

There are a number of examples in Steel etc. that use lambda references
like this:

(mapcar 
  #'(lambda(arg0 arg1 arg2 ...)(...function here)) 
  {list 0} {list 1} {list 2}...
 )

slong