How to use optional and unknow amount of arguments?

This is a discussion on How to use optional and unknow amount of arguments? within the lisp forums in Programming Languages category; What is the best reference manual for common lisp? And one that follows the ANSI standard and thus works for both allegro, sbcl etc....

Go Back   Application Development Forum > Programming Languages > lisp

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-23-2008, 04:39 PM
ssecorp
Guest
 
Default How to use optional and unknow amount of arguments?

What is the best reference manual for common lisp?
And one that follows the ANSI standard and thus works for both
allegro, sbcl etc.
Reply With Quote
  #2  
Old 08-23-2008, 04:49 PM
Mikael Jansson
Guest
 
Default Re: How to use optional and unknow amount of arguments?

On Aug 23, 10:39*pm, ssecorp <circularf...@gmail.com> wrote:
> What is the best reference manual for common lisp?
> And one that follows the ANSI standard and thus works for both
> allegro, sbcl etc.


Try the HyperSpec. http://www.lispworks.com/documentati...ront/index.htm
(lisp.org is down at the moment).

If you're using a Debian-based distribution, you can apt-get the
package "hyperspec".

--
Mikael Jansson
Reply With Quote
  #3  
Old 08-23-2008, 05:26 PM
Barry Margolin
Guest
 
Default Re: How to use optional and unknow amount of arguments?

In article
<75229419-af0f-443d-acd3-607d678bdd94@w7g2000hsa.googlegroups.com>,
ssecorp <circularfunc@gmail.com> wrote:

> What is the best reference manual for common lisp?
> And one that follows the ANSI standard and thus works for both
> allegro, sbcl etc.


Did you really intend to ask a different question in the body of your
message than in the Subject? Did you start out wanting to ask questions
about argument lists, but then change your mind and forget to change the
subject?

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Reply With Quote
  #4  
Old 08-23-2008, 05:33 PM
ssecorp
Guest
 
Default Re: How to use optional and unknow amount of arguments?

Thanks, also I forgot to actually ask the questions.

1. How to use optional arguments?

2. How to handle unknown amount of arguments? in scheme it is ". args"
Reply With Quote
  #5  
Old 08-23-2008, 05:52 PM
Barry Margolin
Guest
 
Default Re: How to use optional and unknow amount of arguments?

In article
<496c3148-ceb1-4c42-b3ef-d1721cffa9fc@m36g2000hse.googlegroups.com>,
ssecorp <circularfunc@gmail.com> wrote:

> Thanks, also I forgot to actually ask the questions.
>
> 1. How to use optional arguments?


http://www.lispworks.com/documentati...Body/03_da.htm

The simple case is like this:

(defun foo (a &optional b c) ...)

B and C are optional, and default to NIL when not supplied. Read the
Hyperspec for the details on how to specify a different default and how
to tell whether the argument was supplied or defaulted.

>
> 2. How to handle unknown amount of arguments? in scheme it is ". args"


In CL it's "&rest args".

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Reply With Quote
  #6  
Old 08-23-2008, 06:29 PM
Jens Teich
Guest
 
Default Re: How to use optional and unknow amount of arguments?

ssecorp <circularfunc@gmail.com> writes:

> What is the best reference manual for common lisp?
> And one that follows the ANSI standard and thus works for both
> allegro, sbcl etc.



Read Peter Seibels Practical Common Lisp, online available at
http://www.gigamonkeys.com/book/

Jens

Reply With Quote
  #7  
Old 08-24-2008, 03:22 AM
Tamas K Papp
Guest
 
Default Re: How to use optional and unknow amount of arguments?

On Sat, 23 Aug 2008 14:33:14 -0700, ssecorp wrote:

> Thanks, also I forgot to actually ask the questions.


You also forgot to read an into book before asking very, very basic
questions. Paul Graham's ANSI Common Lisp and Peter Seibel's Practical
Common Lisp come to mind. The second is available online. Both are good
investments to own in dead tree format.

Tamas
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 01:27 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.