From: Ozgur Can Leonard
Subject: returning multiple values?
Date: 
Message-ID: <63og1s$rro$1@apakabar.cc.columbia.edu>
I need to figure out a way to return more than one value ..  

I admit: it is for my hwk assignment, and I missed class one too many
times, and now I need to know how the functions (value) and
(multiple-value-bind) (i'm not too sure about the args) work. 

If anyone has a decent book and wouldnt mind helping me out, I would
be most grateful. 

Can
····@columbia.edu <- Hint Hint!

From: Christopher N. Vogt
Subject: Re: returning multiple values?
Date: 
Message-ID: <345FCC24.E602502A@home.com>
Ozgur Can Leonard wrote:
> 
> I need to figure out a way to return more than one value ..
> 
> I admit: it is for my hwk assignment, and I missed class one too many
> times, and now I need to know how the functions (value) and

I assume you really mean (values) and not (value)

> (multiple-value-bind) (i'm not too sure about the args) work.
> 
> If anyone has a decent book and wouldnt mind helping me out, I would
> be most grateful.

I won't recommend a book, but you can find the definitions of these on-line
at http://www.harlequin.com/education/books/HyperSpec/FrontMatter/index.html
From: Thomas A. Russ
Subject: Re: returning multiple values?
Date: 
Message-ID: <ymira8vuvlk.fsf@sevak.isi.edu>
····@ahnnyong.cc.columbia.edu (Ozgur Can Leonard) writes:

> 
> 
> I need to figure out a way to return more than one value ..  
> 
> I admit: it is for my hwk assignment, and I missed class one too many
> times, and now I need to know how the functions (value) and
> (multiple-value-bind) (i'm not too sure about the args) work. 

OK, here are a couple examples to help you out.  You can try running
them in your environment and experiment based on them:

(defun gimme (n)
   (case n
     (0 (values))
     (1 (values 'first))    ;; This could also just be 'first
     (2 (values 'first 'second))
     (3 (values 'first 'second (+ 1 2)))))

(multiple-value-bind (a b c) (gimme 0)
  (format t "A = ~S     B = ~S    A = ~S" a b c)
  (list a b c))

(multiple-value-bind (a b c) (gimme 1)
  (format t "A = ~S     B = ~S    A = ~S" a b c)
  (list a b c))

(multiple-value-bind (a b c) (gimme 2)
  (format t "A = ~S     B = ~S    A = ~S" a b c)
  (list a b c))

(multiple-value-bind (a b c) (gimme 3)
  (format t "A = ~S     B = ~S    A = ~S" a b c)
  (list a b c))


You can also try them just at top level:

(gimme 0)
(gimme 1)
(gimme 2)
(gimme 3)

to see what happens.


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