This is a non-technical question. I'm just curious why Mathematica breaks the convention that parentheses are widely used for function arguments. What's the advantage of f[x]
over f(x)
?
Again, for the derivative of a function, f'(x)
and f''(x)
are more familiar than f'[x]
and f''[x]
. I think these conventions in math textbooks have already existed for hundreds of years.
If function arguments are denoted as f(x)
, then array[i]
could be used as array index. (c.f. Mathematica uses array[[i]]
here.)
To quote from the official documentation:
The Four Kinds of Bracketing in the Wolfram Language
(term)
parentheses for grouping
f[x]
square brackets for functions
{a, b, c}
curly braces for lists
v[[i]]
double brackets for indexing (Part[v, i]
)
Are there any historical or antithetical reasons for choosing these notations?
Answer
The answer is quite simple. Most people want to multiply numbers without having to use the *
symbol, e.g. 3x
vs 3*x
.
So given that this exists in Mathematica, using ()
for function arguments would introduce ambiguity.
Is f(x + y)
meant to be f[x + y]
or f*(x + y)
?
This is actually a problem Wolfram|Alpha can face since we try to allow for all forms of inputs.
Other languages like C chose the other route, which means you must use *
to indicate multiplication (something that annoys me). Given that Mathematica's original purpose was for mathematics, I think the right choice was made.
Comments
Post a Comment