This question already has an answer here:
I'm confused about the logic behind mathematica programming.
We can have function that will be called doing $f[x]$, thus the element $f[x]$ can be seen as the return value of a function taking an argument $x$ as input.
However, we can also write :
Here, $a$ is not seen as the return value of a function but as a variable named $a$ that has the value $2$.
Now let's take a more tricky example and I do the following :
f[x_] := x^2; f 1 f 4 f = 100; f 100 f 4
As we can see, I can replace the value $f$ by $100$, but the function still exists in the end.
My questions :
- What is exactly the quantity $a$ in my example. In another programming language we would call it an array but here it is different.
- What happens in mathematica when I did the replacement $f=100;$ Because it didn't destroyed the function ($f$ still had a value), but in the same time the function doesn't exist for the value $1$. I don't understand what mathematica does exactly. In a lot of other programming languages, this wouldn't be a valid operation this $f=100;$.
Actually my questions are also to understand the philosophy behind the language.