From: Frode Vatvedt Fjeld
Subject: Re: Newbie - Access arbitrary number of elements in list?
Date: 
Message-ID: <2hlmaxnde1.fsf@vserver.cs.uit.no>
TejimaNoHimitsu <····@test.com> writes:

> Anyone know of a way I might be able to do this?  Thanks!

Perhaps list* is the function you are looking for? It works just like
list, except the last argument is spliced onto the end:

  (list* 0 '(1 2) 3 '(4 5 6))
  => (0 (1 2) 3 4 5 6)

-- 
Frode Vatvedt Fjeld

From: Barry Margolin
Subject: Re: Newbie - Access arbitrary number of elements in list?
Date: 
Message-ID: <_uEB8.17$pH2.414@paloalto-snr2.gtei.net>
In article <··································@4ax.com>,
TejimaNoHimitsu  <····@test.com> wrote:
>Thanks for the suggestion, but list* won't do what I'm looking for....
>
>I'm trying to do this:
>
>(<fcn here> '(1 2 3))  =>  1 2 3
>
>or at least some method of iterating over all the elements in a list
>(which is the (cddr y) in this case) and return them.... 

Like I said in my other message, it would help if you showed us ADD-L, as
we need to know what it's doing with the argument you supply to it.

Currently, you're supplying it a single list argument, but the list element
of that list is another list, which was returned by CDDR.  If ADD-L expect
everything to be in the top-level list, LIST* should accomplish what you
want:

(add-l (list* j (car item) (cddr item)))

will supply ADD-L a single list whoise 2nd through nth elements correspond
to the 2nd through nth elements of ITEM.

Since we don't know what ADD-L does, there's no way for us to know if it
will do the right thing with this.

-- 
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.
From: Barry Margolin
Subject: Re: Newbie - Access arbitrary number of elements in list?
Date: 
Message-ID: <sHEB8.28$vD6.109@paloalto-snr1.gtei.net>
In article <··································@4ax.com>,
TejimaNoHimitsu  <····@test.com> wrote:
>(defun add-l (toAdd i)
>      (setf (elt *tree* i) (append (list toAdd) 
>(reverse (get-l i))))
>               *tree*)
>
>and in case you need it.....
>
>(defun get-l (i)
>               (reverse (elt *tree* i)))
>
>
>Hope that helps =)

Yes.  Now I'm almost certain that changing:

(list j (car y) (cddr y))

to:

(list* j (car y) (cddr y))

will do what you want.

BTW, (append (list x) <something>) is the same as (cons x <something>).

-- 
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.
From: Frode Vatvedt Fjeld
Subject: Re: Newbie - Access arbitrary number of elements in list?
Date: 
Message-ID: <2hhelkooju.fsf@vserver.cs.uit.no>
TejimaNoHimitsu <····@test.com> writes:

> I'm trying to do this:
>
> (<fcn here> '(1 2 3))  =>  1 2 3

Well, values-list does this. However I suspect if you presented your
original problem a little better, better solutions could be found.

-- 
Frode Vatvedt Fjeld
From: Frode Vatvedt Fjeld
Subject: Re: Newbie - Access arbitrary number of elements in list?
Date: 
Message-ID: <2hd6w8om92.fsf@vserver.cs.uit.no>
TejimaNoHimitsu <····@test.com> writes:

> Sorry about that.  Like the subject says, I'm a newbie so I'm not
> 100% sure how to word my lisp questions ;)

That's ok, but it seems to me you have yet to learn the most basic
evaluation rules, so perhaps you should look for an introductory text.

This crash course should clear up at least one of the things you
apparently have misunderstood, and with some luck help you solve your
problem:

  (values 0 1 2)
  => 0
  => 1
  => 2  ; this means the form returned the three values 0, 1, and 2.

  (list (values 0 1 2) (values 'a 'b 'c 'd))
  => (0 a)
  ;; look, normally only the primary value is used when calling functions...

  (multiple-value-call #'list (values 0 1 2) 'hello (values 'a 'b 'c 'd))
  => (0 1 2 hello a b c d)
  ;; ...but the m-v-call special operator changes that.

  (apply #'list 0 (values 'a 'b) (list 'x 'y) (list 'last 'list 'will 'be 'spread))
  => (0 a (x y) last list will be spread)
  ;; apply could well be the function you are looking for.

  (apply #'list '(a b) '(0 1 2 3))
  => ((a b) 0 1 2 3)

>  If I do (values-list '(1 2 3)) I get 
> 1
> 2
> 3
>
> maybe the fact that the elements are on different lines is messing
> that up? =/

No, values-list returns the three values 1, 2, and 3, which is an
ordered set of values. Your lisp system has decided to print that set
of values one value per line, but it could be printed any number of
other ways. Just like the integer number five can be printed "5",
"#x5", "#b101", or whatever, but it's still the same number five.

-- 
Frode Vatvedt Fjeld
From: Thomas A. Russ
Subject: Re: Newbie - Access arbitrary number of elements in list?
Date: 
Message-ID: <ymilmaub3lr.fsf@sevak.isi.edu>
TejimaNoHimitsu <····@test.com> writes:

> 
> Thanks for the suggestion, but list* won't do what I'm looking for....
> 
> I'm trying to do this:
> 
> (<fcn here> '(1 2 3))  =>  1 2 3
> 
> or at least some method of iterating over all the elements in a list
> (which is the (cddr y) in this case) and return them.... 

Well, there is always MAPCAR:

   (mapcar <fcn> '(1 2 3))  =>   (list (fcn 1) (fcn 2) (fcn 3))

 and then various looping constructs.  The simplest looping version (to
my mind) is

   (loop for element in list
         collect (<fcn> element))


> thanks though =)
> 
> - T

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu