MathGroup Archive 2006

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

Search the Archive

Re: a list as an option

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

On 6/11/06 at 2:16 AM, akane at (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

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

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

{pars -> {a, b, c}}

SetOptions[f, pars -> {d, b, c}]

{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

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

{pars -> {g, b, c}}


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