Erlang Installation
Online page http://www.erlang.org/download.html. Select the appropriate platform on the page. The proposed Erlang learning platform is Linux or UNIX.
For Linux or UNIX-series platforms, download Souce File directly and compile the installation.
| The code is as follows |
Copy Code |
wget http://www.erlang.org/download/otp_src_17.0.tar.gz TAR-XZVF otp_src_17.0.tar.gz CD otp_src_17.0 ./configure Make sudo make install |
After the installation is complete, Erlang's binary path is/usr/local/bin/erl
The Hello World of Erlang
Save the following Hello wolrd program as Hello.erl
| The code is as follows |
Copy Code |
-module (hello). -export ([hello_world/0]). Hello_world ()-> io:fwrite ("Hello, worldn"). |
Compile our hellowolrd, execute the/usr/local/bin/erl into the Erlang Shell, and then enter the following execution on the Erl file just compiled
| The code is as follows |
Copy Code |
ERLANG/OTP [erts-6.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [Kernel-poll:false] Eshell V6.0 (abort with ^g) 1> C (Hello). {Ok,hello} Execute HelloWorld 2> Hello:hello_world (). Hello, world Ok |
Well, Erlang's HelloWorld is done.
How to exit the Erlang Shell
First into the Erlang Shell, overwhelmed, how to exit it?
There are several ways to exit the Erlang shell
Command mode 1: Execute Init:stop ().
Command mode 2: Execute Halt ().
Shortcut key Way 1:control+c then choose a
Shortcut key Way 2:control+g then press Q