-
Notifications
You must be signed in to change notification settings - Fork 32
LanguageReference
Variables start with uppercase and can’t be set twice (single assignment)
A = 2
to change it’s value assign to a new variable
B = A + 1
each expressions ends with a new line, you can make multiline extensions escaping the new line with the ‘\’ character
E = 12 + \
5 * 2
arithmetic expressions are like any programming language
A = (2 + 3) * (6 / (B + 1)) - 5 % 2
logic expressions are like python
(true or false) xor false and not true
binary operations are like C/C++/Java and similar languages
Bin = (2 << 5) | (255 & ~0)
different ways to express numbers (decimal, hexadecimal, octal, binary)
D = 12 + 0xf - 0o10 + 0b1101
strings
S = "Hello"
S1 = "World"
S2 = S ++ " " ++ S1
the basic types supported are integers, floats, booleans, strings which you saw above and lists, tuples, binaries and atoms.
List = [1, 2, 3, 4]
commas are not required
List1 = [2 3 4 5]
lists can contain any type inside (even other lists)
List2 = [1 2.0 false ["another list"]]
tuples are like lists but once you define them you can’t modify them
Tuple = (1, 2, 3, 4)
tuples can also be specified without commas
Tuple1 = (1 2 3 4)
and also can contain anything inside them
Tuple2 = (1 2.0 false ["a list" ("another" "tuple")])
binaries are a type that contains binary data inside them, you can store numbers or even a binary string (common strings are represented as lists internally)
Bin1 = <[1, 2, 3, 4]>
you can have a string represented as a binary
Bin2 = <["mariano"]>
an atom is a named constant. It does not have an explicit value.
A = foo
T = (foo bar baz)
they may seem useless at first, but believe me, they will be useful.