Tom Lieber's Microblog

Apr 9, 2023

TIL the difference between With and ReplaceAll in Mathematica. I thought this would produce the same value twice:

a = b;
With[{b = 42}, a]
ReplaceAll[a, b -> 42]

But the second line evaluates to b and the third line to 42.

With evaluates before the substitution from a to b.