Can we say that “all functions in Mathematica are some kind of pattern-matching-and-replacement procedures”? [duplicate]

Currently I am studying Mathematica programming, and when I study pattern matching and replacement, I find it is quite similar to functions. So can we say "all functions in Mathematica are some kind of pattern-matching-and-replacement procedures"?

• For a start, look up DownValues in the docs. – Michael E2 Apr 17 '15 at 1:44
• @MichaelE2 Thanks for your advice! – username123 Apr 17 '15 at 1:49
• Here are a couple of answers that (at some point) address your question: mathematica.stackexchange.com/questions/3394/…, mathematica.stackexchange.com/questions/24988/…. There are probably others. The point certainly has arisen several times, though I don't know if anyone has asked it straight out like this. See also: mathematica.stackexchange.com/questions/96/… – Michael E2 Apr 17 '15 at 1:55
• One notable example where this is not the case are pure functions. But, unless I am forgetting something, it seems to indeed be the only one. – Leonid Shifrin Apr 17 '15 at 3:33
• Actually, I also forgot compiled functions, as the posted answer reminded me (but compiled functions are relatively rarely created at runtime, unlike pure functions). – Leonid Shifrin Apr 17 '15 at 15:21

f = Compile[{{x, _Real}}, x*x]

There aren't any replacement rules for f in this case.
DownValues[f]

• Try OwnValues[f]. – Michael E2 Apr 17 '15 at 10:11