# Pure functions vs normal functions [duplicate]

I am trying to understand the true difference/usage of a pure function vs a "normal" function. Besides the argument that a pure function is particularly handy when it comes to a single usage, are there any deeper reasons on why one should go for them rather than the "normal" ones?

• I think the pros discussed on this page generally apply to the Wolfram Language as well: en.wikipedia.org/wiki/Anonymous_function
– ktm
Mar 30, 2019 at 19:33
• Mar 30, 2019 at 21:07

They are inevitable to apply when you use such functions as Map or MapThread mapping binary functions on some expressions. Under binary here I mean functions taking two arguments. In this case, you want that only one position of the binary function is active. Let me give an elementary example. Let

eq = a*x == b;


be a simple equation and assume that we want to divide both parts by a. This can be done as follows:

    Map[Divide[#, a] &, eq]
(*  x == b/a   *)


This is the place, where the pure function is extremely useful.

Disclaimer: yes, I know, that in the latest MMa version there is a special function, DivideSides, to make such things. But this is only an example of operations of this sort. There are many others.

• Suggestion for a better readability : to replace "binary function" by "two variables function". I think that a lot of people will think that binary means some kind of 0/1 or True/False function. (I'm not sure) Mar 30, 2019 at 21:06
• @andre314: Correct as to avoiding misleading the reader. But alas, a "unary" relation (or function) takes one argument, a "binary" relation (or function) takes two arguments, a "ternary" relation", etc.... Mar 30, 2019 at 22:08