Wilang Documentation1.0.0+4

Syntax and operators#

Values and assignment#

A math cell holds numbers, expressions, arrays, strings, units, and booleans. Assign a name with =. Names are case-sensitive, so radius and Radius are different variables.

Example
radius = 3
pi * radius^2
f(x) = x^2 + 1
f(4)

Define a function with f(x) = .... JavaScript syntax such as function(x) { ... } is not supported. Use =, not :=, for an assignment you want to run.

Value Example
Integer, decimal, scientific 42, 3.14, 1e-6
Hexadecimal, binary, octal 0xff, 0b1010, 0o17
Complex 2 + 3i
String "hello"
Vector, matrix [1,2,3], [1,2;3,4]
Unit 5 cm, 90 km/h
Boolean, special true, false, Infinity, NaN, null

Operators#

Operation Syntax
Add, subtract, multiply, divide +, -, *, /
Power ^
Element-wise multiply, divide, power .*, ./, .^
Factorial, modulus !, % or mod
Transpose, conjugates complex entries '
Compare ==, !=, <, <=, >, >=
Logic and, or, xor, not
Range start:end, start:step:end
Convert units to, in
Conditional condition ? yes : no

Parentheses group expressions. A power binds before a leading minus sign, so write (-2)^2 when the sign belongs inside the power. Implicit multiplication accepts 2pi and 3(x+1), but an explicit * is easier to read in a long expression. Wrap a whole denominator in parentheses rather than relying on the special precedence rules for division.

Example
(-2)^2
2^3^2
[1,2,3] .* [4,5,6]
1:2:7
true ? 10 : 20

Comments#

A # starts a comment that runs to the end of the line.

Example
2 + 3 # add two values

// is not a math comment. The app reads it as a directive marker, so a plain // note after an expression is a parse error.

See interactive variables and animating plots.

Several statements in one cell#

Give each calculation its own cell. The result stays readable, and dependencies stay clear. Inside one cell, a semicolon separates statements and shows only the last result, so 1; 2; 3 displays 3. A string passed to evaluate uses the same language.

Constants and scope#

pi, e, tau, phi, and i are built in. All constants also lists aliases and scientific constants that carry units. An assignment affects later cells in the same note only, never another note or the REPL. See Variables and REPL.

Calling functions#

Write name(argument, ...). Overloads and array support vary per function, so check the function reference for the exact syntax and a working example. Most numeric operations accept compatible numeric types, but not every function accepts every type.