Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

RE: Functions with Options

  • To: mathgroup at
  • Subject: [mg31990] RE: [mg31984] Functions with Options
  • From: "David Park" <djmp at>
  • Date: Sat, 15 Dec 2001 01:30:09 -0500 (EST)
  • Sender: owner-wri-mathgroup at

You almost got it. Use

newPlot[f_, {x_, min_, max_}, opts___?OptionQ] := Plot[f, {x, min, max},

The difference is that opts has 3 underscores after it instead of 2. Two
underscores means 1 or more arguments. Three underscores mean 0 or more
arguments. The ?OptionQ is just an added check that makes sure it is a
sequence of rules.

David Park
djmp at

> From: guillerm at [mailto:guillerm at]
To: mathgroup at
> [Please moderator, delete my previouos E mail]
> I would like build functions with Options using Mathematica
> build-up functions
> with the same options.
> Here is a naïf example:
> newPlot[f_, {x_, min_, max_}, opts__] := Plot[f, {x, min, max}, opts]
> If I use this function given options the solution is OK. i.e:
> newPlot[Sin[x], {x, 0 , 2 Pi}, PlotRange -> All]
> but, of course, it doen`t work if it not included options. i.e:
> In[]:= newPlot[Sin[x], {x, 0 , 2 Pi}]
> Out[]:= newPlot[Sin[x], {x, 0, 2 Pi}]
> How it should be made the function in the way that it works given
> or not given
> values for options.
> Thanks

  • Prev by Date: Re: Functions with Options
  • Next by Date: Re: Re: Re: Solve[] for equations?
  • Previous by thread: Re: Functions with Options
  • Next by thread: Re: Functions with Options