Exotic Programming Ideas, Part 2: Term Rewriting
What's the magic going on in substitutions like:<p><pre><code>    Sin[a+b] /. Sin[x_] -> Cos[x]
</code></pre>
which yields 'Cos[a+b]'. Is the underscore after the x what indicates that "x_" can take any value? And Mathematica then strips the undescore and replaces 'x' with that value? Why not just use x_ on both sides? And earlier the author was using '_x' instead of 'x_'. It seems rather mysterious to me.