Skip to content

Instantly share code, notes, and snippets.

@iaintshine
Created February 13, 2013 01:17
Show Gist options
  • Save iaintshine/1f4c698d291bfabbb053 to your computer and use it in GitHub Desktop.
Save iaintshine/1f4c698d291bfabbb053 to your computer and use it in GitHub Desktop.
Erlang echo example
-module(echo).
-compile(export_all).
go() ->
register(echo, spawn(echo, loop, [])),
echo ! { self(), hello },
receive
{ _Pid, Msg } ->
io:format("~w~n", [Msg])
end,
echo ! stop.
loop() ->
receive
{ From, Msg } ->
From ! { self(), Msg },
loop();
stop ->
true
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment