MathGroup Archive 2008

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

Search the Archive

Re: Evaluate part of rhs of RuleDelayed


> I am writing a lazy recursive function (actually, a tree of UI widgets
> that is too large to be constructed at once).
> Consider, for example, the following code:
> SomeComplexFunction[a_] := Module[{x},
>   x = a*a;
>   {value :> SomeComplexFunction[x + a]}]
> The value of SomeComplexFunction[5] is {value :>
> SomeComplexFunction[x$7418 + 5]} and seemingly can'd be used for
> anything useful.
> Question:
> How should I fix the code of SomeComplexFunction so that the value of
> SomeComplexFunction[5] be {value :> SomeComplexFunction[30]} ?
> Unfortunately, this one
> SomeComplexFunction[a_] := Module[{x},
>   x = a*a;
>   {value :> SomeComplexFunction[Evaluate[x + a]]}]
> yields {value :> SomeComplexFunction[Evaluate[x$7421 + 5]]}

If I understood correctly what you try to do you should look at With,
which is your friend when working with partially evaluated expressions:

SomeComplexFunction[a_] := Module[{x},
  x = a*a;
  With[{arg = x + a},
   {value :> SomeComplexFunction[arg]}

On the other hand, I have the feeling that your problem might be solved
in a better way if you give more detailed information on what you are
trying to achieve with SomeComplexFunction...



  • Prev by Date: Re: RadioButton Question
  • Next by Date: Re: How to get objects closer to each other in a Graphics Grid?
  • Previous by thread: Re: Evaluate part of rhs of RuleDelayed
  • Next by thread: Re: Evaluate part of rhs of RuleDelayed