Re: Defining a Function with an Indeterminate Number of Arguments
- To: mathgroup at smc.vnet.net
- Subject: [mg81286] Re: Defining a Function with an Indeterminate Number of Arguments
- From: mcmcclur at unca.edu
- Date: Tue, 18 Sep 2007 00:47:08 -0400 (EDT)
- References: <fclbai$fh8$1@smc.vnet.net>
On Sep 17, 3:45 am, Donald DuBois <don... at comcast.net> wrote:
> I am trying to define a function with the following two properties:
> (A) The function should be able to take an indeterminate number of
> arguments without using the List structure (like the Which or
> StringJoin functions in Mathematica).
> (B) The function should have the capability of defining and using
> options in the usual way
Here's a simple way to do it:
testFunc[x___, opts___Rule] := {x, Test /. {opts}}
Note that x and opts both match zero or more arguments.
The pattern matcher matches the most specific instance
of a pattern; thus, opts matches whatever rules appear
at the end of the list of arguments.
Mark