From: Tony
Subject: Seeking help with building lists
Date: 
Message-ID: <dbcm5g$q30$1@nnrp.waia.asn.au>
Hi.

I'm learning Lisp and I'd be grateful if someone could help me with the
following problem.

I'm trying to determine a general method of combining multiple values into a
single list.

I have tried the following (unsuccessful) methods:

(list (values 1 2) (values 'a 'b))

(1 A)

(multiple-value-list (values 1 2) (values 'a 'b))

(1 2)

In the above instances, I'm trying to return the list (1 2 'a 'b).

Any help would be much appreciated.

Tony

From: Eric Lavigne
Subject: Re: Seeking help with building lists
Date: 
Message-ID: <1121579039.619167.197040@z14g2000cwz.googlegroups.com>
I'm trying to determine a general method of combining multiple values
into a
single list.

>I have tried the following (unsuccessful) methods:
>
>(list (values 1 2) (values 'a 'b))
>
>(1 A)
>
>(multiple-value-list (values 1 2) (values 'a 'b))
>
>(1 2)
>
>In the above instances, I'm trying to return the list (1 2 'a 'b).

Here is the solution to the particular problem that you gave:

(append (multiple-value-list (values 1 2)) (multiple-value-list (values
'a 'b)))
  --> (1 2 A B)

It's rather inelegant though. This is just crying out for a macro:
(multiple-multiple-value-list (values 1 2) (values 'a 'b) (values 'and
'so 'on))
  --> (1 2 A B AND SO ON)

I haven't figured out how to write such a macro, though. Assuming it
would start like this...
(defmacro multiple-multiple-value-list (&rest rest) ...

I don't see how to splice the arguments, though.
From: Ulf Wikstr?m
Subject: Re: Seeking help with building lists
Date: 
Message-ID: <4a10db93.0507170300.671f21df@posting.google.com>
"Eric Lavigne" <············@gmail.com> wrote in message news:<························@z14g2000cwz.googlegroups.com>...
> I'm trying to determine a general method of combining multiple values
> into a
> single list.
> 
> >I have tried the following (unsuccessful) methods:
> >
> >(list (values 1 2) (values 'a 'b))
> >
> >(1 A)
> >
> >(multiple-value-list (values 1 2) (values 'a 'b))
> >
> >(1 2)
> >
> >In the above instances, I'm trying to return the list (1 2 'a 'b).
> 
> Here is the solution to the particular problem that you gave:
> 
> (append (multiple-value-list (values 1 2)) (multiple-value-list (values
> 'a 'b)))
>   --> (1 2 A B)
> 
> It's rather inelegant though. This is just crying out for a macro:
> (multiple-multiple-value-list (values 1 2) (values 'a 'b) (values 'and
> 'so 'on))
>   --> (1 2 A B AND SO ON)
> 
> I haven't figured out how to write such a macro, though. Assuming it
> would start like this...
> (defmacro multiple-multiple-value-list (&rest rest) ...
> 
> I don't see how to splice the arguments, though.

Here's one way to do it:

(defmacro multiple-multiple-value-list (&body body)
  `(append ,@(mapcar #'(lambda (v) `(multiple-value-list ,v)) body)))

I hope I didn't make a fool out of myself now! :)
From: Gareth McCaughan
Subject: Re: Seeking help with building lists
Date: 
Message-ID: <87irz9zp3x.fsf@g.mccaughan.ntlworld.com>
Eric Lavigne wrote:

> It's rather inelegant though. This is just crying out for a macro:
> (multiple-multiple-value-list (values 1 2) (values 'a 'b) (values 'and
> 'so 'on))
>   --> (1 2 A B AND SO ON)
> 
> I haven't figured out how to write such a macro, though. Assuming it
> would start like this...
> (defmacro multiple-multiple-value-list (&rest rest) ...

(defmacro multiple-multiple-value-list (&rest value-producing-forms)
  (cond
    ((null value-producing-forms) 'nil)
    ((null (rest value-producing-forms))
     `(multiple-value-list ,(first value-producing-forms)))
    (t `(nconc (multiple-value-list ,(first value-producing-forms))
               (multiple-multiple-value-list . ,(rest value-producing-forms))))))

will do it, for instance.

-- 
Gareth McCaughan
.sig under construc
From: Tim X
Subject: Re: Seeking help with building lists
Date: 
Message-ID: <87u0ium1ff.fsf@tiger.rapttech.com.au>
"Tony" <··········@email.com> writes:

> Hi.
> 
> I'm learning Lisp and I'd be grateful if someone could help me with the
> following problem.
> 
> I'm trying to determine a general method of combining multiple values into a
> single list.
> 
> I have tried the following (unsuccessful) methods:
> 
> (list (values 1 2) (values 'a 'b))
> 
> (1 A)
> 
> (multiple-value-list (values 1 2) (values 'a 'b))
> 
> (1 2)
> 
> In the above instances, I'm trying to return the list (1 2 'a 'b).
> 
> Any help would be much appreciated.
> 

Not quite sure I understand exactly what you want as

CL-USER> (list 1 2 'a 'b)
(1 2 A B)
CL-USER> 

seems to do what you are after or are you after something which will
return a flat list even when the arguments might themselves be lists
or some other requirement I'm not getting from your problem
description?

Tim

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!
From: http://public.xdi.org/=pf
Subject: Re: Seeking help with building lists
Date: 
Message-ID: <m2vf39di68.fsf@mycroft.actrix.gen.nz>
On Sun, 17 Jul 2005 14:23:49 +1000, Tony  wrote:

> Hi.
> I'm learning Lisp and I'd be grateful if someone could help me with the
> following problem.

> I'm trying to determine a general method of combining multiple values into a
> single list.

> I have tried the following (unsuccessful) methods:

> (list (values 1 2) (values 'a 'b))

> (1 A)

> (multiple-value-list (values 1 2) (values 'a 'b))

> (1 2)

I'd expect an error.

> In the above instances, I'm trying to return the list (1 2 'a 'b).

> Any help would be much appreciated.

(multiple-value-call #'list (values 1 2) (values 'a 'b))


-- 
Don't worry about people stealing your ideas. If your ideas are any good,
you'll have to ram them down people's throats.
                                                          -- Howard Aiken
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(··@) "actrix.gen.nz>"))
From: Tony
Subject: Re: Seeking help with building lists
Date: 
Message-ID: <dbd89s$vqa$1@nnrp.waia.asn.au>
You've solved my problem.  Thanks everyone for your help with this.

Tony