From: Barry Margolin
Subject: Re: Newbie - Access arbitrary number of elements in list?
Date: 
Message-ID: <raDB8.14$pH2.421@paloalto-snr2.gtei.net>
In article <··································@4ax.com>,
TejimaNoHimitsu  <····@test.com> wrote:
>I'm having a tough time with a particular part of a program I have to
>write.  Please look at the following snippit of code:
>
>
>(mapcar #'(lambda (y)
>         (cond ((equal (car y) (elt x (+ 1 (position '* x))))
>                   (add-l (list j  (car y) (cddr y)) j)))) text
>                        )

I've re-indented this so that the structure is more visible:

(mapcar #'(lambda (y)
	    (cond ((equal (car y) (elt x (+ 1 (position '* x))))
                   (add-l (list j  (car y) (cddr y))
			  j))))
	text)

>add-l is another function I defined that does stuff, but that's not
>important.  The part that bothers me is the (cddr y) part because it
>keeps returning a list when in fact I want each individual element in
>that list.  For example, the above code currently yields
>
>((2 Fred (eats cake)))  
>
>whereas I want it to yield
>
>((2 Fred eats cake))   .............. but I dunno how =/

ADD-L *is* important, since it's constructing the returned data.  Without
knowing what kind of arguments it expects or how they're used in creating
the returned data, it's kind of difficult to know what's wrong.

But I'm going to take a wild guess and suggest that you use LIST* instead
of LIST.  With LIST*, the last argument is used as the tail of the
resulting list, rather than just as the last element.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.