Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!news.mathworks.com!newsfeed.internetmci.com!news.sprintlink.net!tank.news.pipex.net!pipex!edi.news.pipex.net!pipex!dish.news.pipex.net!pipex!dircon!rheged!simon
From: simon@rheged.dircon.co.uk (Simon Brooke)
Subject: Re: Behaviour of MAPCAR
Message-ID: <DBxDu0.7wK@rheged.dircon.co.uk>
Organization: none. Disorganization: total.
References: <3udfe7$66h@sparcserver.lrz-muenchen.de>
Date: Tue, 18 Jul 1995 18:53:58 GMT
Lines: 53

In article <3udfe7$66h@sparcserver.lrz-muenchen.de>,
Stephan Kepser <kepser@cis.uni-muenchen.de> wrote:
>Hi,
>
>when debugging my program I discovered the following behaviour of MAPCAR  
>(in Lucid CommonLisp v.4.1.1), which astonished me:
>
>>(mapcar #'(lambda (x) '*a*) '(a b)
>(*a* *a*)
>
>>(mapcar #'(lambda (x) '*a*) '(a . b)
>(*a*)
>
>The first operation, the one on true (i.e. non-dotted) lists, works as  
>expected. But what about the second? 

It works as expected too.

>When discussing mapping functions (7.8.4, p. 171 ff), CLtL2 only speaks  
>about lists, 

Just so. MAPCAR takes as it's second argument a list: that is, a cons
cell whose CDR is a list. It doesn't take a dotted pair, which is not
a list.

>And what  
>mapcar is suppossed to do with the end of a list, is - in my eyes - open  
>to interpretation. All, that said is
>
>	First the function is applied to the car of each list,
>	then to the cadr of each list, and so on. 
>	                             (CLtL2, p.171)
>
>So "and so on" till what? 

Till the end of the list.

>The explanation seems to imply that mapcar is  
>supposed to work on true lists.

It does.

>How should things work? Could someone please explain.

As they do. LUCID's behaviour is correct, and any other behaviour
would astonish me. There is, after all, no CADR of a dotted pair.


-- 
------- simon@rheged.dircon.co.uk (Simon Brooke)

	There are no messages. The above is just a random stream of
	bytes. Any opinion or meaning you find in it is your own creation.
