Skip to main content
2 of 5
added 109 characters in body
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

#1

Trott-Strzebonski in-place evaluation:

hf = HoldForm[1 - 1^2/2 + 1^3/3 - 1^4/4 + 1^5/5 - 1^6/6]

hf /. x_Times :> With[{eval = x}, eval /; True]
1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6
Replace[hf, x_ :> With[{eval = x}, eval /; True], {2}]
1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6

#2

Injector pattern:

{1, -(1/2), 1/3, -(1/4), 1/5, -(1/6)} /. {x__} :> HoldForm[Plus[x]]
1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k