Org-mode test
(require 'org-tempo)
(require 'ob-erlang)
(org-babel-do-load-languages
'org-babel-load-languages
'((erlang . t)
(shell . t)))
start() ->
io:format("hello world").
Start REPL
erl
Eshell V10.3.5.9 (abort with ^G)
1> *** Terminating erlang (nonode@nohost)
Language elements
Arithmetic
3+4.
Operations
- +,-,*,/
- div (division without remainder)
- rem (remainder of whole number division)
-
Lists
A = [2,3,4].
hd(A).
Lambda expressions
(fun (X) -> X+X end)(99).
Primitive data types
- Numbers
- Integer - Bignums, arbitrarily large and full precision
- Numbers with different base:
2#10010011
for example is binary.
- Atoms
- written with small letter in the first place:
foo
- written in single quotes:
'i am an atom'
- compare:
==
- order:
>, <
- special atoms:
true, false
- Booleans:
true
false
- Tuples:
- pieces of data, put together in curly braces:
{1,2,3,{4,5}}
- often data is tagged tuples:
{<atom describing the tuple>, <payload>}
for example: {rectangle, {0, 0}, {2, 3}}
- data can be heterogenous
- immutable, must be built in one go
- Lists:
- in square brackets:
[elem1, elems]
- data can be heterogenous, often is homogenous
- append operation:
++
- length:
length/1
- Strings:
- list of characters
- characters are numbers
- ASCII code for a character:
$<char>
- Functions:
- anonymous function syntax:
fun (<args> ...) -> <exprs> ... end