Re: a list as an option
- To: mathgroup at smc.vnet.net
- Subject: [mg67189] Re: a list as an option
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sun, 11 Jun 2006 23:07:50 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <e6gd7r$n9j$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Akane Tendo wrote:
> Hello,
>
> If I have a function f with options like:
> Options[f]=[...,{pars->{a,b,c}}]
> How can I change just one of 'pars' options ('a', 'b' or 'c')?
> I tried to change, for example, 'a' to 'd' like this:
> SetOptions[f,pars[[1]]->d]
> But it didn't work.
> I also tried to access the option:
> Options[f,pars]
> And the result is: {}
> Does anyone know what am I doing wrong or if it's not possible at all to
> have a list as an option?
>
> Thank you!!
>
>
Hi Akane,
I think the following expression (In[]) will do what you want. Say you
want to change the second parameter of the list pars:
In[1]:=
Options[f] = {pars -> {a, b, c}}
Out[1]=
{pars\[Rule]{a,b,c}}
In[2]:=
Options[f] = Options[f] /.
(pars -> {x_, y_, z___}) -> pars -> {x, e, z}
Out[2]=
{pars\[Rule]{a,e,c}}
In[3]:=
Options[f]
Out[3]=
{pars\[Rule]{a,e,c}}
HTH,
Jean-Marc