MathGroup Archive 2001

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

Search the Archive

RE: Functions with Options


You almost got it. Use

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

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 earthlink.net
http://home.earthlink.net/~djmp/

> From: guillerm at usal.es [mailto:guillerm at usal.es]
To: mathgroup at smc.vnet.net
>
> [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