Ubuntu 21.10にErlangをインストールする方法

OSバージョンの確認
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.10
DISTRIB_CODENAME=impish
DISTRIB_DESCRIPTION="Ubuntu 21.10″

1.パッケージのアップデート
# sudo apt update

2.Erlangをインストールします
# sudo apt install erlang

3.Erlang実行確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# erl
Erlang/OTP 23 [erts-11.1.8] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]
Eshell V11.1.8 (abort with ^G)
1>
# erl Erlang/OTP 23 [erts-11.1.8] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] Eshell V11.1.8 (abort with ^G) 1>
# erl
Erlang/OTP 23 [erts-11.1.8]  [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Eshell V11.1.8  (abort with ^G)
1>

計算結果を行う

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
2> 6+8.
14
2> 6+8. 14
2> 6+8.
14

終了
3> halt().

4.ファイルのコンパイル実行
# nano test.erl
以下の内容を編集します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
-module(test).
-export([h/0]).
h() ->
io:format("study skill become smart").
-module(test). -export([h/0]). h() -> io:format("study skill become smart").
-module(test).
-export([h/0]).

h() ->
    io:format("study skill become smart").

ファイルをコンパイルして実行します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# erl
Erlang/OTP 23 [erts-11.1.8] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]
Eshell V11.1.8 (abort with ^G)
1> c(test).
{ok,test}
2> test:h().
study skill become smartok
3> q().
ok
# erl Erlang/OTP 23 [erts-11.1.8] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] Eshell V11.1.8 (abort with ^G) 1> c(test). {ok,test} 2> test:h(). study skill become smartok 3> q(). ok
# erl
Erlang/OTP 23 [erts-11.1.8]  [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Eshell V11.1.8  (abort with ^G)
1> c(test).
{ok,test}
2> test:h().
study skill become smartok
3> q().
ok

 

Ubuntu 21.10

Posted by arkgame