MathGroup Archive 2005

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

Search the Archive

Re: Options in user-defined functions...

  • To: mathgroup at
  • Subject: [mg60375] Re: Options in user-defined functions...
  • From: Bill Rowe <readnewsciv at>
  • Date: Wed, 14 Sep 2005 03:27:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 9/13/05 at 6:07 AM, danwolf80_no_spam_ at (Daniele Lupo)

>I've a little problem with a function. I've defined it in this way:


>So, when I use it, ops have their default values.

>It works, but I'd like to use option; this why, if I want to change
>only op3, I must to write every argument when I call the function,
>while I'd like to write something like this:


>how can I do it?

Basically, you need to rewrite your function along the lines of:

SetOptions[fun, op1->1, op2->2, op3->3];

fun[x_, opts___]:=

A couple of additional thoughts. The package Utilities`FilterOPtions` is quite handy when creating functions with options. It allows you to call other functions which have options, ensuring each function gets only those options applicable to it.

Roman Maeder presents a very clear discussion of options versus default values in chapter 3 of his book Programming in Mathematica.
To reply via email subtract one hundred and four

  • Prev by Date: Batch
  • Next by Date: Re: Generate a palette with a FrontEnd Token
  • Previous by thread: Re: Options in user-defined functions...
  • Next by thread: Re: Options in user-defined functions...