MathGroup Archive 2000

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

Search the Archive

Re: A function to evaluate only parts matching a pattern


Another form for evaluating at positions:

EvaluateAt2[expr_, pos_, f_:Identity] :=
  Replace[MapAt[#1, #2, #3],
        #1[x_] :> RuleCondition[f[x]], {0, Infinity}
        ] &[Unique[A], expr,
    Switch[pos, _Integer, {{pos}}, {__Integer}, {pos}, _, pos]]

EvaluateAt2[expr, {{1}, {1, 3, 1}}, #^2 &]

Hold[(5 + Hold[25])^2]

EvaluateAt2[expr, {1, 3, 1}, #^2 &]

Hold[2 + 3 + Hold[25]]

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565





  • Prev by Date: No pictures/diagrams in help
  • Next by Date: using FindRoot with a list of starting values
  • Previous by thread: Re: A function to evaluate only parts matching a pattern
  • Next by thread: Re: A function to evaluate only parts matching a pattern