Getting Used to the Wolfram Language
■ Arguments of functions are given in square brackets. |
■ Names of built‐in functions have their first letters capitalized. |
■ Multiplication can be represented by a space. |
■ Powers are denoted by ^. |
■ Numbers in scientific notation are entered, for example, as 2.5*^-4 or 2.5*10^-4. |
If you have used other computer systems before, you will probably notice some similarities and some differences. Often you will find the differences the most difficult parts to remember. It may help you, however, to understand a little about why the Wolfram Language is set up the way it is, and why such differences exist.
One important feature of the Wolfram Language that differs from other computer languages, and from conventional mathematical notation, is that function arguments are enclosed in square brackets, not parentheses. Parentheses in the Wolfram Language are reserved specifically for indicating the grouping of terms. There is obviously a conceptual distinction between giving arguments to a function and grouping terms together; the fact that the same notation has often been used for both is largely a consequence of typography and of early computer keyboards. In the Wolfram Language, the concepts are distinguished by different notation.
This distinction has several advantages. In parenthesis notation, it is not clear whether means c[1+x] or c*(1+x). Using square brackets for function arguments removes this ambiguity. It also allows multiplication to be indicated without an explicit * or other character. As a result, the Wolfram Language can handle expressions like 2x and ax or a (1+x), treating them the same as in standard mathematical notation.
You can also see from "Some Mathematical Functions" that built‐in Wolfram Language functions often have quite long names. You may wonder why, for example, the pseudorandom number function for generating reals is called RandomReal, rather than, say, Rand. The answer, which pervades much of the design of the Wolfram Language, is consistency. There is a general convention in the Wolfram Language that all function names are spelled out as full English words, unless there is a standard mathematical abbreviation for them. The great advantage of this scheme is that it is predictable. Once you know what a function does, you will usually be able to guess exactly what its name is. If the names were abbreviated, you would always have to remember which shortening of the standard English words was used.
Another feature of built‐in Wolfram Language names is that they all start with capital letters. "Defining Variables" and "Defining Functions" discuss how to define variables and functions of your own. The capital letter convention makes it easy to distinguish built‐in objects. If the Wolfram Language used max instead of Max to represent the operation of finding a maximum, then you would never be able to use max as the name of one of your variables. In addition, when you read programs written in the Wolfram Language, the capitalization of built‐in names makes them easier to pick out.
Uppercase and lowercase letters are recognized as different characters. Lists are wrapped with curly brackets.
{a,b,B}
{a,b,B}
Built-in symbols are capitalized. Commas are used to separate arguments. A semicolon suppresses output, but the command is still evaluated.
N[Pi,50];
N[Pi,50];