WolframLang: Principles
Principle of Wolfram Language Syntax
- Everything is a Expression.
- Expression is either an atom, or a list of atoms in the form
a[b, c, etc]
, arbitrarily nested. - Atom is a number (
3.4
), a Symbol (x
), a string ("cat"
), or special character (\[Pi]
). - There are many short syntax for function or function call. e.g.
List[1,2,3]
can be written as{1,2,3}
, andSet[x,2]
can be written asx=2
, andPlus[1,2]
can be written as1+2
. WolframEngine transform any short syntax to the fully nested forma[b, c, etc]
internally before computation. 〔see WolframLang: Syntax, Operators Cheatsheet〕
- WolframLang code is just a sequence of expressions, practically just function calls. Knowing what function to call is the essence of coding WolframLang. 〔see WolframLang: Find Function by Name, List All Functions〕
How Does Wolfram Language Do Computation
There are 2 ways WolframLang does computation.
- Function call. Either builtin or user defined. e.g.
Plus[3, 2]
,Sin[3]
,Range[5]
,If[3 > 2, "yes", "no"]
- Syntactical transformation by pattern matching and replacement. (aka term rewriting system)