Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!torn!watserv2.uwaterloo.ca!watserv3.uwaterloo.ca!watermidge
From: MACHAPUT@ARTSU1.uwaterloo.ca (Matthew Allan Chaput)
Subject: Re: Variable number of arguments
Message-ID: <45u7fu$b20_001@watstar.uwaterloo.ca>
Sender: news@watserv3.uwaterloo.ca
Nntp-Posting-Host: watermidge.watstar.uwaterloo.ca
Organization: University of Waterloo
X-Newsreader: News Xpress Version 1.0 Beta #3
References: <d.brown.4.0014BC0F@intelsat.int> <45p0a4$rvo@cerberus.ibmoto.com>
Date: Mon, 16 Oct 1995 18:15:26 GMT
Lines: 42

In article <45p0a4$rvo@cerberus.ibmoto.com>, tim@apple.com (Tim Olson) 
wrote:
>In article <d.brown.4.0014BC0F@intelsat.int>
>d.brown@intelsat.int (David Brown) writes:
>
>> I would like to write a routine with a variable number of arguments
>> For example, a calendar date to julian date routine could be called
>> in several ways
>> 
>> 1. (cal2jul mon day yr hr min sec)
>> 2. (cal2jul '(mon day yr) '(hr min sec))
>> 3. (cal2jul mon day yr)
>
>all of the arguments to a function can be bound to a single variable
>using the following notation:
>
>(define (cal2jul . rest)
>   ;; rest is a list of all of the arguments
>
>the code in cal2jul then checks the contents of rest to determine what
>form was used.
>
>
>        -- Tim Olson
>        Apple Computer, Inc. / Somerset
>        tim@apple.com

I would just add that you CAN require some arguments, and then assign 
the remaining arugments provided to a name:

(define (foo req1 req2 . rest)
  ...)

Later,

Matt Chaput
machaput@artsu1.uwaterloo.ca



------------------------------------------------------------------------------
Matthew Allan Chaput
