MathGroup Archive 2006

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

Search the Archive

Re: a list as an option

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67206] Re: a list as an option
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Sun, 11 Jun 2006 23:08:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 6/11/06 at 2:16 AM, akane at netvisao.pt (Akane Tendo) wrote:

>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?

There is no difficulty in having a list as an option. Changing the first element of the list could be done as follows:

In[39]:=
Options[f] = {pars -> {a, b, c}}

Out[39]=
{pars -> {a, b, c}}

In[40]:=
SetOptions[f, pars -> {d, b, c}]

Out[40]=
{pars -> {d, b, c}}

Or if you can't know the length of the list before hand or the values of each of the other elements

In[42]:=
SetOptions[f, pars -> (pars /. Options[f] /. 
    {x_, y__} -> {g, y})]

Out[42]=
{pars -> {g, b, c}}

In[43]:=
Options[f]

Out[43]=
{pars -> {g, b, c}}
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: a list as an option
  • Next by Date: Re: List manipulation question
  • Previous by thread: Re: a list as an option
  • Next by thread: Can Mathematica handle this TeX?