MathGroup Archive 2005

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

Search the Archive

Re: Passing options through user-defined functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59001] Re: [mg58967] Passing options through user-defined functions
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 26 Jul 2005 04:02:45 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Joe,

Something like this...

foo[p_, q_, opts___?OptionQ] :=
Module[
	{bar},
	bar = Table[
		f[x, y],
		{x, 1, p}, {y, 1, q}
	];
	ArrayPlot[bar, opts, ImageSize -> 500]
]

I don't see how your overall function and plot is going to work. Don't
forget to use the underscore pattern indicator when defining the function.
Notice that I built an option into the ArrayPlot statement. Any options
passed would be applied first and hence if you passed ImageSize as an option
it would be applied and not the built in one. If you are going to pass
options to several routines you might want to look into the
Utilities`FilterOptions package, but it usually isn't necessary. You can
pass the actual options and don't have to decode your own version of them.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: Joe Christy [mailto:joe at eshu.net]
To: mathgroup at smc.vnet.net


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

For example, I have something like

foo[p,q]:=
Module[
	{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}]
--
============================= Joe Christy ==============================
------------------ http://public.xdi.org/=joe.christy ------------------
== If I can save you any time, give it to me, I'll keep it with mine. ==



  • Prev by Date: Re: Re: Re: Re: Mathematica 5.2: The 64-bit and multicore release
  • Next by Date: VersionHistory[ commandName] would be nice (was Mathematica 5.2: The 64-bit and...)
  • Previous by thread: Re: Passing options through user-defined functions
  • Next by thread: Fedora Core 4?