erlangを動かしてみる

話題のerlang(アーラン)を動かしてみる。
以下のページを参考にしてさわりだけ。。。
http://d.hatena.ne.jp/m-hiyama/20070515/1179203855

インストール

yum install erlang

インストール確認

# erl
Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]

Eshell V5.5 (abort with ^G)
1>

檜山氏と同じことをしてみる

1> X=10.
10
2> X=10.
10
3> X=9.

=ERROR REPORT==== 30-May-2007::00:01:06 ===
Error in process <0.31.0> with exit value: {{badmatch,9},[{erl_eval,expr,3}]}

exited: {{badmatch,9},[{erl_eval,expr,3}]} **

4> X!=9.

1: syntax error before: '=' **

4> X>9.
true
5> X==9.
false
6>

終わらせ方(ctrl + Gの後でq)
# erl
Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]

Eshell V5.5 (abort with ^G)
1>
User switch command
--> q
#

桧山氏の真似をしてハローワールド出してみる

ファイルの内容

-module(sample).

  • export([hello_world/0]).

実行してみる

hello_world() -> io:fwrite("Hello, World!\n").
[root@nattu-vaio 2ca3]# erl
Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]

Eshell V5.5 (abort with ^G)
1> c(sample).
{ok,sample}
2> sample:hello_world().
Hello, World!
ok
3>

Programming Erlang: Software for a Concurrent World
Joe Armstrong
Pragmatic Bookshelf (2007/07)
売り上げランキング: 37