MathGroup Archive 2000

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

Search the Archive

Re: A function to evaluate only parts matching a pattern

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25761] Re: A function to evaluate only parts matching a pattern
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 21 Oct 2000 14:43:14 -0400 (EDT)
  • References: <8se9n3$6ps@smc.vnet.net> <8sjhpt$fpm@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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