Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

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



  • 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