From: ···········@gmail.com
Subject: Assigning values from a list
Date: 
Message-ID: <b2e1d8c1-5a67-420d-a365-bc28ebb5a8f7@18g2000hsf.googlegroups.com>
I was wondering how you do something like this (written in Python), in
Common Lisp:

a, b, c = [2, 3, 5]

Is there some macro or function to assign multiple values from a list
to variables?

From: Pascal Costanza
Subject: Re: Assigning values from a list
Date: 
Message-ID: <5sp8m7F1a7rg4U1@mid.individual.net>
···········@gmail.com wrote:
> I was wondering how you do something like this (written in Python), in
> Common Lisp:
> 
> a, b, c = [2, 3, 5]
> 
> Is there some macro or function to assign multiple values from a list
> to variables?

(destructuring-bind (x y z) (list 2 3 5)
   (psetq a x b y c y))

The rest is just a macro definition away...


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: ···········@gmail.com
Subject: Re: Assigning values from a list
Date: 
Message-ID: <0e9199ac-b576-432f-bc86-452061b5c843@f3g2000hsg.googlegroups.com>
On Dec 18, 7:46 am, Pascal Costanza <····@p-cos.net> wrote:
> ···········@gmail.com wrote:
> > I was wondering how you do something like this (written in Python), in
> > Common Lisp:
>
> > a, b, c = [2, 3, 5]
>
> > Is there some macro or function to assign multiple values from a list
> > to variables?
>
> (destructuring-bind (x y z) (list 2 3 5)
>    (psetq a x b y c y))
>
> The rest is just a macro definition away...
>
> Pascal
>
> --
> My website:http://p-cos.net
> Common Lisp Document Repository:http://cdr.eurolisp.org
> Closer to MOP & ContextL:http://common-lisp.net/project/closer/

How about this one as well? I cooked it up after going to Peter
Seibel's Practical Common Lisp. I had already studied that book, but
somehow this stuff had slipped my mind obviously. Anyway, here's what
I've found in the meantime:

(setf (values a b c) (values-list '(2 3 5)))
From: Dan Bensen
Subject: Re: Assigning values from a list
Date: 
Message-ID: <fkclll$m3c$1@wildfire.prairienet.org>
···········@gmail.com wrote:
> (setf (values a b c) (values-list '(2 3 5)))

No, VALUES isn't quite that flexible.  I've never
seen VALUES used anywhere except where the values
are received by one of the multiple-value-* forms.
You also can't use it as function arguments.

-- 
Dan
www.prairienet.org/~dsb/
From: Rob Warnock
Subject: Re: Assigning values from a list
Date: 
Message-ID: <6tSdnbEJAPp9ePTanZ2dnUVZ_qKgnZ2d@speakeasy.net>
Dan Bensen  <··········@cyberspace.net> wrote:
+---------------
| ···········@gmail.com wrote:
| > (setf (values a b c) (values-list '(2 3 5)))
| 
| No, VALUES isn't quite that flexible.
+---------------

Uh... Actually, Sir, it certainly *is*!!

    http://www.lisp.org/HyperSpec/Body/sec_5-1-2-3.html
    5.1.2.3 VALUES Forms as Places

    A values form can be used as a place, provided that each
    of its subforms is also a place form.
    ...
    (setf (values place-1 ...place-n) values-form) 

For example:

    > (deflex a 'a)    ; Pardon my DEFLEX, less typing than (defvar *a* ...)

    A
    > (deflex b (list 'b 'bb 'bbb))

    B
    > (deflex c (vector 'c 'cc 'ccc 'cccc))

    C
    > (list a b c)

    (A (B BB BBB) #(C CC CCC CCCC))
    > (setf (values a (second b) (aref c 2)) (values-list '(2 3 5)))

    2
    3
    5
    > (list a b c)

    (2 (B 3 BBB) #(C CC 5 CCCC))
    > 

+---------------
| I've never seen VALUES used anywhere except where the values
| are received by one of the multiple-value-* forms.
+---------------

Well, now you have!  ;-}  ;-}

+---------------
| You also can't use it as function arguments.
+---------------

You can, but of course you'll only pass the first one:

    > (list (values 1 2 3) (values 4 5 6 7) (values 8 9) 10)

    (1 4 8 10)
    >

Though if you do want to pass *all* the values, have a look at:

    http://www.lisp.org/HyperSpec/Body/speope_multiple-value-call.html
    ...
    (multiple-value-call #'list 1 '/ (values 2 3) '/ (values) '/ (floor 2.5))
    =>  (1 / 2 3 / / 2 0.5)


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Dan Bensen
Subject: Re: Assigning values from a list
Date: 
Message-ID: <fkda5f$sal$1@wildfire.prairienet.org>
 > Dan Bensen  <··········@cyberspace.net> wrote:
 > | No, VALUES isn't quite that flexible.

Rob Warnock wrote:
 > Uh... Actually, Sir, it certainly *is*!!

Thanks, that's good to know.

 > | You also can't use it as function arguments.
 > You can, but of course you'll only pass the first one

That's why I specified the plural, you can't pass more than one.

 > http://www.lisp.org/HyperSpec/Body/speope_multiple-value-call.html

Like I said, multiple values work with the multiple-values-* forms.

-- 
Dan
www.prairienet.org/~dsb/
From: ···········@gmail.com
Subject: Re: Assigning values from a list
Date: 
Message-ID: <f989ecf4-ddce-4490-8fbe-d102a04b1fa7@e6g2000prf.googlegroups.com>
On Dec 20, 9:47 am, Dan Bensen <··········@cyberspace.net> wrote:
>  > Dan Bensen  <··········@cyberspace.net> wrote:
>  > | No, VALUES isn't quite that flexible.
>
> Rob Warnock wrote:
>
>  > Uh... Actually, Sir, it certainly *is*!!
>
> Thanks, that's good to know.
>
>  > | You also can't use it as function arguments.
>  > You can, but of course you'll only pass the first one
>
> That's why I specified the plural, you can't pass more than one.
>
>  >http://www.lisp.org/HyperSpec/Body/speope_multiple-value-call.html
>
> Like I said, multiple values work with the multiple-values-* forms.
>
> --
> Danwww.prairienet.org/~dsb/

It seems like most of us agree that VALUES and VALUES-LIST are cool
and useful. The example I had given is explicative I think, but there
IS one minor problem. Suppose you wanted to initialize several global
variables at the same time, you'd have to first use, say, DEFPARAMETER
(eg. (DEFPARAMETER *A* NIL), (DEFPARAMETER *B* NIL), and so on) and
then SETF, which of course is slightly more verbose than the Python
version unfortunately. It seems there's no way around this one, but
maybe somebody will prove me wrong (I hope).

Here's the whole example:

(DEFPARAMETER *A* NIL)
(DEFPARAMETER *B* NIL)
(DEFPARAMETER *C* NIL)
(SETF (VALUES *A* *B* *C*) (VALUE-LIST '(2 3 5)))

Anybody know how to shorten that?
From: Jason Cornez
Subject: Re: Assigning values from a list
Date: 
Message-ID: <b1fa21ea-3415-45ec-919e-2bc3df69d3d0@c4g2000hsg.googlegroups.com>
On Dec 20, 12:18 pm, ···········@gmail.com wrote:

> Here's the whole example:
>
> (DEFPARAMETER *A* NIL)
> (DEFPARAMETER *B* NIL)
> (DEFPARAMETER *C* NIL)
> (SETF (VALUES *A* *B* *C*) (VALUE-LIST '(2 3 5)))
>
> Anybody know how to shorten that?

Well, you can always write a macro. Something like...

(defmacro defparams (&rest vars)
  `(progn
     ,@(loop for (var val desc) in vars
             collect `(defparameter ,var ,val ,desc))))

Then you can say...

(defparams (*a* 2 "my a")
           (*b* 3)
           (*c* 5 "my c"))

Or if you know that you never want documentation strings, you can do
the following...

(defmacro defparams (&rest vars)
  `(progn
     ,@(loop for (var val) on vars by #'cddr
             collect `(defparameter ,var ,val))))

(defparams *a* 2 *b* 3 *c* 5)

Or maybe you want...

(defmacro defparams (vars vals)
  `(progn
     ,@(loop for var in vars and val in vals
             collect `(defparameter ,var ,val))))

(defparams (*a* *b* *c*) (2 3 5))

-Jason
From: ···········@gmail.com
Subject: Re: Assigning values from a list
Date: 
Message-ID: <34908be0-bffc-4036-8118-5712d33d9a51@p1g2000hsb.googlegroups.com>
On Dec 20, 1:30 pm, Jason Cornez <·······@alum.mit.edu> wrote:
> On Dec 20, 12:18 pm, ···········@gmail.com wrote:
>
> > Here's the whole example:
>
> > (DEFPARAMETER *A* NIL)
> > (DEFPARAMETER *B* NIL)
> > (DEFPARAMETER *C* NIL)
> > (SETF (VALUES *A* *B* *C*) (VALUE-LIST '(2 3 5)))
>
> > Anybody know how to shorten that?
>
> Well, you can always write a macro. Something like...
>
> (defmacro defparams (&rest vars)
>   `(progn
>      ,@(loop for (var val desc) in vars
>              collect `(defparameter ,var ,val ,desc))))
>
> Then you can say...
>
> (defparams (*a* 2 "my a")
>            (*b* 3)
>            (*c* 5 "my c"))
>
> Or if you know that you never want documentation strings, you can do
> the following...
>
> (defmacro defparams (&rest vars)
>   `(progn
>      ,@(loop for (var val) on vars by #'cddr
>              collect `(defparameter ,var ,val))))
>
> (defparams *a* 2 *b* 3 *c* 5)
>
> Or maybe you want...
>
> (defmacro defparams (vars vals)
>   `(progn
>      ,@(loop for var in vars and val in vals
>              collect `(defparameter ,var ,val))))
>
> (defparams (*a* *b* *c*) (2 3 5))
>
> -Jason

Very nice Jason. Macros are just so powerful. This is really what sets
Lisp apart from the rest. Thanks for your simple and elegant solution.

Rock
From: Jeff Shrager
Subject: Re: Assigning values from a list
Date: 
Message-ID: <df05195d-2c70-47c6-9984-8416802ef43e@y5g2000hsf.googlegroups.com>
> Very nice Jason. Macros are just so powerful. This is really
> what sets Lisp apart from the rest. Thanks for your simple
> and elegant solution.

Good, so you're now just one baby step from an epiphany: You get the
macros now, so you should also now get the parens! (Hint: You couldn't
do macros without the parens, or, more generally, without the concept
of all code being represented as lisp-processable data structure.)
From: ···········@gmail.com
Subject: Re: Assigning values from a list
Date: 
Message-ID: <daa3a86d-f079-4dd5-8a72-86179bf5fbdb@q70g2000hsd.googlegroups.com>
On 20 Dic, 23:16, Jeff Shrager <········@gmail.com> wrote:
> > Very nice Jason. Macros are just so powerful. This is really
> > what sets Lisp apart from the rest. Thanks for your simple
> > and elegant solution.
>
> Good, so you're now just one baby step from an epiphany: You get the
> macros now, so you should also now get the parens! (Hint: You couldn't
> do macros without the parens, or, more generally, without the concept
> of all code being represented as lisp-processable data structure.)

Yeah, the parens are at the heart of it all. Lisp is homo-iconic so
the difference between programs and data is really blurred. Powerful
stuff indeed :)

Well, I followed your examples and got to reading as much as I could
about macros (On Lisp, Practical Common Lisp) and here's what I cooked
up. It should allow doc strings for global defparams as well:

(defmacro defparams-from-list (vars vals &optional (docs nil))
  (labels ((extend-list (a b)
			 (if (> (length b) (length a))
			     (append a (make-list (- (length b)
						     (length a))))
			   a)))
	   `(progn
	     ,@(loop for var in vars
		     for val in (extend-list vals vars)
		     for doc in (extend-list docs vars)
		     collect `(defparameter ,var ,val ,doc))
	     nil)))


What do you think? Is it ok?
From: viper-2
Subject: Re: Assigning values from a list
Date: 
Message-ID: <7848d000-17d2-4be5-adc3-3db146912356@a35g2000prf.googlegroups.com>
On Dec 22, 12:29 pm, ···········@gmail.com wrote:

> Well, I followed your examples and got to reading as much as I could
> about macros (On Lisp, Practical Common Lisp) and here's what I cooked
> up. It should allow doc strings for global defparams as well:
>
> (defmacro defparams-from-list (vars vals &optional (docs nil))
>   (labels ((extend-list (a b)
>                          (if (> (length b) (length a))
>                              (append a (make-list (- (length b)
>                                                      (length a))))
>                            a)))
>            `(progn
>              ,@(loop for var in vars
>                      for val in (extend-list vals vars)
>                      for doc in (extend-list docs vars)
>                      collect `(defparameter ,var ,val ,doc))
>              nil)))
>
> What do you think? Is it ok?

Bravo, you obviously took the shot!;-))

agt
From: viper-2
Subject: Re: Assigning values from a list
Date: 
Message-ID: <025d3efb-2357-4ed6-a12c-0ec625fcc14d@f3g2000hsg.googlegroups.com>
On Dec 20, 7:30 am, Jason Cornez <·······@alum.mit.edu> wrote:

> Well, you can always write a macro. Something like...


> (defmacro defparams (vars vals)
>   `(progn
>      ,@(loop for var in vars and val in vals
>              collect `(defparameter ,var ,val))))
>
> (defparams (*a* *b* *c*) (2 3 5))
>
> -Jason

Where might one find a highly recommended loop tutorial? My ancient
book mentions it exactly once - in 4 lines - maybe the authors weren't
impressed. I, myself, seem to have acquired a strong dislike for loop.
There appears to be little need for it when DO will do, but it seems
that everyone is looping despite its evidently unlispy syntax. I avoid
loop (which seems like a language of its own imported from elsewhere)
but I'd like to at least be able to translate accurately. ;-)

agt
From: Joost Diepenmaat
Subject: Re: Assigning values from a list
Date: 
Message-ID: <871w9esv4l.fsf@zeekat.nl>
viper-2 <········@mail.infochan.com> writes:

> Where might one find a highly recommended loop tutorial? My ancient
> book mentions it exactly once - in 4 lines - maybe the authors weren't
> impressed. I, myself, seem to have acquired a strong dislike for loop.
> There appears to be little need for it when DO will do, but it seems
> that everyone is looping despite its evidently unlispy syntax. I avoid
> loop (which seems like a language of its own imported from elsewhere)
> but I'd like to at least be able to translate accurately. ;-)

"practical common lisp" has enough information to make loops readable.

http://gigamonkeys.com/book/loop-for-black-belts.html

Joost.
From: viper-2
Subject: Re: Assigning values from a list
Date: 
Message-ID: <b11396de-27d2-4404-81f0-2d53046f8f00@i72g2000hsd.googlegroups.com>
On Dec 22, 8:43 am, Joost Diepenmaat <·····@zeekat.nl> wrote:

> "practical common lisp" has enough information to make loops readable.
>
> http://gigamonkeys.com/book/loop-for-black-belts.html
>
> Joost.

Joost:

Someone from this group drew my attention to Seibel's book some time
ago. I did skim a couple of chapters, but observed that there were no
exercises. However, since you recommend it highly for loop, I'll have
another look. Thank you and Merry Christmas!

agt
From: Maciej Katafiasz
Subject: Re: Assigning values from a list
Date: 
Message-ID: <fkdma0$sn5$4@news.net.uni-c.dk>
Den Thu, 20 Dec 2007 02:47:06 -0600 skrev Dan Bensen:

>  > | You also can't use it as function arguments. You can, but of course
>  > you'll only pass the first one
> 
> That's why I specified the plural, you can't pass more than one.
> 
>  > http://www.lisp.org/HyperSpec/Body/speope_multiple-value-call.html
> 
> Like I said, multiple values work with the multiple-values-* forms.

Well, they're multiple values, so they're designed to work like that. 
Otherwise they wouldn't be any different from ordinary return values. 
D'oh.

Cheers,
Maciej
From: Edi Weitz
Subject: Re: Assigning values from a list
Date: 
Message-ID: <u63yuxdo7.fsf@agharta.de>
On Wed, 19 Dec 2007 20:57:20 -0600, Dan Bensen <··········@cyberspace.net> wrote:

> ···········@gmail.com wrote:
>> (setf (values a b c) (values-list '(2 3 5)))
>
> No, VALUES isn't quite that flexible.  I've never seen VALUES used
> anywhere except where the values are received by one of the
> multiple-value-* forms.

Huh?  Why don't you at least try the example before you spread
unfounded rumors?

  CL-USER 34 > (let (a b c)
                 (setf (values a b c) (values-list '(2 3 5)))
                 (list a b c))
  (2 3 5)

See here:

  http://www.lispworks.com/documentation/HyperSpec/Body/05_abc.htm

> You also can't use it as function arguments.

I can't really parse that sentence, but you might want to look here:

  http://www.lispworks.com/documentation/HyperSpec/Body/s_multip.htm

Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Kent M Pitman
Subject: Re: Assigning values from a list
Date: 
Message-ID: <usl1xhngt.fsf@nhplace.com>
Edi Weitz <········@agharta.de> writes:

> Dan Bensen <··········@cyberspace.net> wrote:
> 
> > You also can't use it as function arguments.
> 
> I can't really parse that sentence, but you might want to look here:
> 
>   http://www.lispworks.com/documentation/HyperSpec/Body/s_multip.htm

I think he means that (f (values 2 3)) doesn't pass two values to f.
But he might not know about multiple-value-call.

And anyway, the notion of discarding the non-primary values on function
isn't a bug, it's a feature.  A great many functions return "extra helpful
but ignorable values".  If doing so meant you had to filter those values
out in order to call the function, all function composition in CL would be
broken.  For example, you couldn't do (+ (truncate 5 2) 1) because you'd
have to worry that truncate would pass both values to +.  You couldn't do
(FUNCALL (GETHASH X *TABLE* *DEFAULT-FN*)) because you'd have to worry that 
GETHASH returns a second value that you didn't want to get involved with
the FUNCALL.

I have said many times, and this is a fine time to repeat it: Language
features are not Good or Bad in some absolute sense; they are good or
bad in a context.  Languages are like ecologies and to understand the 
goodness you must understand how features relate to one another to produce
a unified whole.  The design of CL's multiple values is designed to dovetail
with the way it does function calling and the way various functions return
various things.  We'd have to redefine the whole function library and add
tons more functions if we were going to make function calling rigorously
require matching like I think is being suggested.
From: Dan Bensen
Subject: Re: Assigning values from a list
Date: 
Message-ID: <fkd9h0$s4s$1@wildfire.prairienet.org>
 >> ···········@gmail.com wrote:
 >>> (setf (values a b c) (values-list '(2 3 5)))

 > On Wed, 19 Dec 2007 20:57:20 -0600, Dan Bensen <··········@cyberspace.net> wrote:
 >> No, VALUES isn't quite that flexible.

Edi Weitz wrote:
 > Huh?  Why don't you at least try the example before you spread
 > unfounded rumors?

Sorry.  When I was first learning about VALUES, everything I read
said how great it was, but then it never worked where I wanted
to use it.  You're right though, I should have tried it.

 >> You also can't use it as function arguments.
 > I can't really parse that sentence

I thought
   (defun foo () (values :a :b))
   (bar (foo))
might be equivalent to
   (bar :a :b)

-- 
Dan
www.prairienet.org/~dsb/
From: viper-2
Subject: Re: Assigning values from a list
Date: 
Message-ID: <7127e9df-caef-42c5-9ddf-2a3192caba84@e25g2000prg.googlegroups.com>
On Dec 18, 1:37 am, ···········@gmail.com wrote:
> I was wondering how you do something like this (written in Python), in
> Common Lisp:
>
> a, b, c = [2, 3, 5]
>
> Is there some macro or function to assign multiple values from a list
> to variables?


I have a Lisp text so ancient that it doesn't even
mention DESTRUCTURING-BIND :-)

>
(defmacro multiple-assign (asg-lst var-lst)
  `(multiple-value-bind ,asg-lst
    (values ,@var-lst)
    (list ,@asg-lst)))
MULTIPLE-ASSIGN

>
(multiple-assign (x y z) (7 8 9))
(7 8 9)

>
(multiple-assign (x y z) ('merry 'christmas 'all))
(MERRY CHRISTMAS ALL)

agt
From: Rainer Joswig
Subject: Re: Assigning values from a list
Date: 
Message-ID: <joswig-12468D.19092718122007@news-europe.giganews.com>
In article 
<····································@e25g2000prg.googlegroups.com>,
 viper-2 <········@mail.infochan.com> wrote:

> On Dec 18, 1:37 am, ···········@gmail.com wrote:
> > I was wondering how you do something like this (written in Python), in
> > Common Lisp:
> >
> > a, b, c = [2, 3, 5]
> >
> > Is there some macro or function to assign multiple values from a list
> > to variables?
> 
> 
> I have a Lisp text so ancient that it doesn't even
> mention DESTRUCTURING-BIND :-)
> 
> >
> (defmacro multiple-assign (asg-lst var-lst)
>   `(multiple-value-bind ,asg-lst
>     (values ,@var-lst)
>     (list ,@asg-lst)))
> MULTIPLE-ASSIGN
> 
> >
> (multiple-assign (x y z) (7 8 9))
> (7 8 9)
> 
> >
> (multiple-assign (x y z) ('merry 'christmas 'all))
> (MERRY CHRISTMAS ALL)
> 
> agt

See also MULTIPLE-VALUE-SETQ :

http://www.lisp.org/HyperSpec/Body/mac_multiple-value-setq.html

-- 
http://lispm.dyndns.org/
From: viper-2
Subject: Re: Assigning values from a list
Date: 
Message-ID: <f1e70c7e-0f12-4f12-b682-c743e7ffad8b@f3g2000hsg.googlegroups.com>
On Dec 18, 1:09 pm, Rainer Joswig <······@lisp.de> wrote:
> In article
> <····································@e25g2000prg.googlegroups.com>,

>
> See also MULTIPLE-VALUE-SETQ :

Thanks Rainer. Fortunately, I'm right at the end of this ancient,
apparently pre-CLTL2 (but brilliant), book. Although, it is fun to
write your own functions and macros when you just can't find the right
primitive.

agt
From: Leandro Rios
Subject: Re: Assigning values from a list
Date: 
Message-ID: <47684be0$0$1345$834e42db@reader.greatnowhere.com>
viper-2 escribi�:
> Thanks Rainer. Fortunately, I'm right at the end of this ancient,
> apparently pre-CLTL2 (but brilliant), book. 

May I ask which book is that?

Thanks,

Leandro
From: viper-2
Subject: Re: Assigning values from a list
Date: 
Message-ID: <37e17043-5b9f-490d-bf1a-23df7a67f98e@i29g2000prf.googlegroups.com>
On Dec 18, 5:37 pm, Leandro Rios <··················@gmail.com> wrote:
> viper-2 escribió:
>
> > Thanks Rainer. Fortunately, I'm right at the end of this ancient,
> > apparently pre-CLTL2 (but brilliant), book.
>
> May I ask which book is that?
>
> Thanks,
>
> Leandro

It's "Lisp 3rd edition" by Horn and Winston. My interests are in AI so
I thought I would learn Lisp with an AI slant.

I'm one of the recently returned 4400 so I'm a bit outdated; but yes,
I've heard of PAIP and AIMA by Norvig et al. - and  I'll be studying
areas from both those texts too.;-)

agt
From: Leandro Rios
Subject: Re: Assigning values from a list
Date: 
Message-ID: <47686223$0$1341$834e42db@reader.greatnowhere.com>
viper-2 escribi�:
> 
> It's "Lisp 3rd edition" by Horn and Winston. My interests are in AI so
> I thought I would learn Lisp with an AI slant.
> 
> I'm one of the recently returned 4400 so I'm a bit outdated; but yes,
> I've heard of PAIP and AIMA by Norvig et al. - and  I'll be studying
> areas from both those texts too.;-)
> 

I wasn't going to suggest nothing at all! I just wanted to know the name 
of the book in order to get it. If you're reading an "ancient" book and 
have such a high praise for it, I wanted to know its name in order to 
get it.

Thanks,

Leandro
From: viper-2
Subject: Re: Assigning values from a list
Date: 
Message-ID: <283853dd-2dcc-448b-b46c-40613fb0b259@s19g2000prg.googlegroups.com>
On Dec 18, 7:12 pm, Leandro Rios <··················@gmail.com> wrote:

> I wasn't going to suggest nothing at all! I just wanted to know the name
> of the book in order to get it. If you're reading an "ancient" book and
> have such a high praise for it, I wanted to know its name in order to
> get it.
>

I hope you will enjoy it as much as I did. A word of caution: Chapters
19 - 32, which deal with AI applications, require perseverance, are
for the adventurous - and not for the faint-hearted!

agt
From: Rainer Joswig
Subject: Re: Assigning values from a list
Date: 
Message-ID: <joswig-2A7A3A.21205318122007@news-europe.giganews.com>
In article 
<····································@f3g2000hsg.googlegroups.com>,
 viper-2 <········@mail.infochan.com> wrote:

> On Dec 18, 1:09 pm, Rainer Joswig <······@lisp.de> wrote:
> > In article
> > <····································@e25g2000prg.googlegroups.com>,
> 
> >
> > See also MULTIPLE-VALUE-SETQ :
> 
> Thanks Rainer. Fortunately, I'm right at the end of this ancient,
> apparently pre-CLTL2 (but brilliant), book. Although, it is fun to
> write your own functions and macros when you just can't find the right
> primitive.
> 
> agt

Just for fun - a bit related, about finding code ... :

http://pooh.unl.edu/~scotth/papers/icse96.html
http://pooh.unl.edu/~scotth/papers/TOSEM-henninger97.pdf
http://l3d.cs.colorado.edu/~ostwald/tmp/se91/se91.html
Codefinder, Supporting the Construction and Evolution of Component Repositories
Shows also the user interface of Codefinder on the Symbolics Lisp Machine

-- 
http://lispm.dyndns.org/
From: John Thingstad
Subject: Re: Assigning values from a list
Date: 
Message-ID: <op.t3iv5qg0ut4oq5@pandora.alfanett.no>
P� Tue, 18 Dec 2007 07:37:01 +0100, skrev <···········@gmail.com>:

> I was wondering how you do something like this (written in Python), in
> Common Lisp:
>
> a, b, c = [2, 3, 5]
>
> Is there some macro or function to assign multiple values from a list
> to variables?

Not sure wether this is interesting but the iterate package offers a macro  
dsetq that automates what Pascal wrote and more. (dsetq - destructuring  
set quote'd)

(let (a b c)
   (dsetq ((a b) c) '((1 2) 3))
   (values a b c))

also works for values (like with setf)..

(let (second minute hour)
   (dsetq (values second minute hour) (decode-universal-time  
(get-universal-time)))
   (format t "time: ~D:~D:~D" hour minute second))

..and nil values (nice touch!..

(let (day month year)
   (dsetq (values nil nil nil day month year) (decode-universal-time  
(get-universal-time)))
   (format t "date: ~D/~D-~D" day month year))

..as the the (declare (ignore ...)) anoyance is avoided)

I always felt this macro was *missing* in CL.

--------------
John Thingstad
From: Albert Krewinkel
Subject: Re: Assigning values from a list
Date: 
Message-ID: <fwuy7bs6vof.fsf@pc42.inb.uni-luebeck.de>
"John Thingstad" <·······@online.no> writes:
> På Tue, 18 Dec 2007 07:37:01 +0100, skrev <···········@gmail.com>:
>
>> I was wondering how you do something like this (written in Python), in
>> Common Lisp:
>>
>> a, b, c = [2, 3, 5]
>>
>> Is there some macro or function to assign multiple values from a list
>> to variables?

> Not sure wether this is interesting but the iterate package offers a
> macro dsetq that automates what Pascal wrote and more. (dsetq -
> destructuring  set quote'd)

There's also metabang-bind [1], which offers something similar.  It
combines let, multiple-value-bind and destructuging-bind. Code example
from the website:

(bind ((a 2)  
       ((b &rest args &key (c 2) &allow-other-keys) '(:a :c 5 :d 10 :e 54))  
       ((:values d e) (truncate 4.5)))  
  (list a b c d e args))  
==> (2 :A 5 4 0.5 (:C 5 :D 10 :E 54)) 


[1] http://common-lisp.net/project/metabang-bind/

-- 
Albert Krewinkel