Prolog, Erlang

Prologでhello, world

実行環境はubuntu10.10。

以下を実行してインストール。

$ sudo apt-get install swi-prolog

どうするのが主流なのかよく分からないが、以下のファイルを作成。
[hello.swi]

hello:-write('hello, world').

端末から以下を実行

$ swipl -s hello.swi

プロンプトで

?- hello.

以下が表示される。

hello, world
true.

[終了方法]

?- halt.

erlangでhello, world

ubuntu10.10でerlと打ったら

Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

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

と返ってきたからerlangでもhello, worldしてみる。
まず以下のソースファイルを作成。
[hello.erl]

-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("hello, world\n").

erlangを実行

$ erl

プロンプトからコンパイル

1> c(hello)
コンパイルされ以下が表示される。

{ok,hello}

実行する。

2> hello:hello_world().
以下が表示される。

hello, world
ok

[終了方法]

3> q().