As the future of the code says, in order to make full use of multi-core, concurrency will become the future trend of development, for concurrent programming support, Erlang is indeed the choice, Erlang is still relatively small in China, the classic books are relatively few, and finally chose the Erlang programming 2nd edition As my first Erlang starter book.
Erlang Official website: http://www.erlang.org/
Erlang Installation:
For Ubuntu and Debian distributions, use: Apt-get install Erlang to be installed;
For other UNIX and Linux platforms, you can download the source code and build it manually, as shown in the following example:
Download:http://www.erlang.org/download.html
Copy Code code as follows:
1. Extract source code: $ tar zxf otp_src_17.3.tar.gz
2. $ CD opt_src_17.3
3. $/configure
4. $ make
5. $ make Install
Erlang is a functional programming language that is designed to solve problems such as bottom-up authoring of concurrent, distributed, fault-tolerant, scalable, and soft real-time systems.
Since there has been no contact with functional programming, or from a simple sequential programming step by step.
Erlang into the shell programming environment is very simple, similar to Python, in the terminal directly input Erl, exit can use CTRL + C and enter a method, but this may cause some data damage, preferably using Q ().
Note:%
variable: All variable names must start with an uppercase letter, and variables are assigned and are not allowed to change.
Pattern matching operations:
Lhs = Rhs meaning is to compute the value on the right side, and then match the result to the pattern on the left;
x = Expression, if x has not been assigned before, will definitely match the success, x = Anotherexpression, then only in Expression = anotherexpression match success, otherwise the match fails;
Floating point numbers:
When "/" is used to divide two integers, the result is automatically converted to floating-point numbers;
To get integers from except Farey, you must use DIV and REM; for example: 5 div 3. Results for 1,5 REM 3. The result was 2;
Atomic:
Atoms are used to represent constant values that are global, with atoms beginning with lowercase letters, followed by a string of letters, numbers, underscores, or @ symbols;
Atoms can be placed in single quotes to create atoms that start with a capital letter or contain characters other than alphanumeric, such as ' Monday ', ' + ', ' A Test paper ', and so on, the value of an atom is itself;
META Group:
For easy understanding, tuples are best tagged, for example: {point, 10, 45}.
Create tuple: F = {firstName, Joe}. L = {lastName, Tom}. P = {person, F, L}.
Extract Firstname:{_, {_, who}, {_, _}} = P.
List:
Each element in the list can be of any type, [h| T] h is the list header, T is the end of the list, for example:
L = [{name, Tom}, 1, 2.0, test, {point, 10, 23}].
[h| T] = L.
Then, H = {name, Tom}, T = [1, 2.0, test, {point, 10, 23}].
String:
A string literal is a string of characters enclosed in double quotes, such as:
N = "Hello". "Hello" is simply a shorthand for a list that contains the integer code that represents each character in the string.
X = [97, 98, 99].
Print out "ABC".
Io:format ("~w~n", ["ABC"]).
Print out [97, 98, 99]
[h| T] = "Cat". H =, T = "at".
F () Let the shell forget any existing bindings.