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 2005

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

Search the Archive

Re: Passing options through user-defined functions

  • To: mathgroup at
  • Subject: [mg59013] Re: Passing options through user-defined functions
  • From: Bill Rowe <readnewsciv at>
  • Date: Tue, 26 Jul 2005 04:03:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 7/25/05 at 1:30 AM, joe at (Joe Christy) wrote:

>I have a function implemnted as module which uses various builtin
>functions. What is the best way to pass options to the builtin

>For example, I have something like

>   {bar},
>   bar=Table[
>       f[x,y],
>       {x,1,p},{y,1,q}
>   ];
>   ArrayPlot[bar]

>and I would like to be able to write something like

>foo[3,5, size -> 100]

>and see the results of ArrayPlot[bar, ImageSize->{3*100,5*100}]

Your specific example could be done as follows:

    ArrayPlot[bar,ImageSize->size {p,q}/.opts]

You may also find it useful to define default options for foo using


Also if you use options frequently in your functions you will find the package Utilities`FilterOptions` useful. The FilterOptions package allows you to have options for your function as well as the called functions. Assuming this package is loaded your example could become

    ArrayPlot[barImageSize->size {p,q}/.opts,

With this version you can include any of the options for ArrayPlot as arguements to foo.
To reply via email subtract one hundred and four

  • Prev by Date: Problem with loading SuperWidgetPackage
  • Next by Date: Re: Re: Re: Re: Mathematica 5.2: The 64-bit and multicore release
  • Previous by thread: Re: Passing options through user-defined functions
  • Next by thread: Re: Passing options through user-defined functions