Summary: The features of Erlang are almost different from those of Erlang...
Variable immutable:
Guarantees atomicity and prepares for parallelism.
Tuples:
Similar to the structure in C language.
Person = {person, {name,joe}, {height,1.82}. }.
List:
[H | T]. The list starts with H and ends with T. The vertical line symbol (|) can separate the header and tail of the list, while [] is an empty list.
ThingsToBuy = [{apples,10},{pears,6},{milk,3}].
Pattern Matching:
= Indicates a pattern matching operation. LHS = RHS is actually such a process, evaluate the right end (RHs), and then match the result with the left end (LHS) pattern.
38 P.
Recursion:
General Syntax:
total([Head|Tail]) ->some_function_of(Head) + total(Tail);total([]) -> 0.
Example:
-module(mylists).-export([sum/1]).sum([H|T]) -> H + sum(T);sum([]) -> 0.
Process:
Sum ([1, 3, 10]) = 1 + sum (3, 10)
= 1 + 3 + sum ([10])
= 1 + 3 + 10 + sum ([])
= 1 + 3 + 10 + 0
= 14
List parsing:
(Erlang-my@thomescai-G41MT-S2)4> L = [1,2,3,4].[1,2,3,4](Erlang-my@thomescai-G41MT-S2)5> [2*X || X <- L].[2,4,6,8]
[F (x) | x <-L] indicates a list composed of f (x), where X is set to list L. Therefore, [2 * x | x <-L] means "List of each element x in list l multiplied by 2".
Arithmetic expression:
P57.
Assertion example:
The assertion sequence can be a single assertion or a series of assertion sets separated by semicolons. In the assertion set G1; G2 ;...; In gn, As long as any asserted is true, the entire asserted sequence is true.
F (x, y) When is_integer (x), x> Y, Y <6->...
Record:
Records are tuples.
Eshell V5.8.3 (abort with ^G)1> rr("records.hrl").[todo]2> X=#todo{}.#todo{status = reminder,who = joe,text = undefined}3> X1 = # todo{status=urgent,text="Fix errata in book"}.#todo{status = urgent,who = joe,text = "Fix errata in book"}4> X2 = X1#todo{status=done}.#todo{status = done,who = joe,text = "Fix errata in book"}