notes.org 1.8 KB

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

  1. Numbers
  2. Integer - Bignums, arbitrarily large and full precision
  3. Numbers with different base: 2#10010011 for example is binary.
  4. Atoms
  5. written with small letter in the first place: foo
  6. written in single quotes: 'i am an atom'
  7. compare: ==
  8. order: >, <
  9. special atoms: true, false
  10. Booleans:
  11. true
  12. false
  13. Tuples:
  14. pieces of data, put together in curly braces: {1,2,3,{4,5}}
  15. often data is tagged tuples: {<atom describing the tuple>, <payload>} for example: {rectangle, {0, 0}, {2, 3}}
  16. data can be heterogenous
  17. immutable, must be built in one go
  18. Lists:
  19. in square brackets: [elem1, elems]
  20. data can be heterogenous, often is homogenous
  21. append operation: ++
  22. length: length/1
  23. Strings:
  24. list of characters
  25. characters are numbers
  26. ASCII code for a character: $<char>
  27. Functions:
  28. anonymous function syntax: fun (<args> ...) -> <exprs> ... end