MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Defining a Function with an Indeterminate Number of Arguments


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



  • Prev by Date: coupled map lattice problem
  • Next by Date: Re: Button Help Example
  • Previous by thread: Defining a Function with an Indeterminate Number of Arguments
  • Next by thread: Re: Defining a Function with an Indeterminate Number of Arguments