kongkuren erlang 1

-module(echo).
-export([go/0, loop/0]).

go() ->
Pid = spawn(echo, loop, []),
Pid ! {self(), hello},
receive
{Pid, Msg} ->
io:format(“~w~n”,[Msg])
end,
Pid ! stop.

loop() ->
receive
{From, Msg} ->
From ! {self(), Msg},
loop();
stop ->
true
end.

how to run:
1. go to folder dimana file itu disimpan (cd bla bla)
2. ketik erl
3. c(echo).
4. go().

WARN: tanda titik.

Kaitkata:

Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s


Ikuti

Get every new post delivered to your Inbox.