- atoms
true
,hello
,'WORLD'
- binary
<<"Hello World">>
- Useful for unicode characters
- lists
[1,2,3]
"Hello, World"
(a string of characters [which are just integers])
- tuples
{greeting, <<"Hello there!">>}
- integers
12345
- max value of ram
- Single assignment variables start with an uppercase character
- The
=
operatorA = 10.
{RecordType, Car} = {car, "Challenger"}.
Message = "Hello, world!".
- map (just like ruby map)
- filter (just like ruby select)
- List comprehension (map)
A = [1,2,3,4,5].
[X * 2 || X <- A].
[2,4,6,8,10]
- List comprehension (filter)
A = [1,2,3,4,5].
[X || X <- A, X rem 2 == 0]
- Build in reverse for constant time list insertion the use lists:reverse(List).
- Arity (number of parameters a function takes)
- call function in tail position to reuse call frame (bindings)
- last call in function is "tail"
- Module and Process are useful for code decomposition
- Akin to a Class
erlc
(to compile .erl to .beam)erl -pa
(for load path)m(module_name)
gives info about modulec("/path/to/file.erl")
orc(demo)
to compile- _Variable (ignore variable)
-
Comma separates sequentially executing statements (,)
X = 2, X1 = X+2, X2 = X1 + 2.
-
Semicolon separates related but distinct things (;)
- see even_or_odd
-
Period terminates a block of things or a single thing (.)