Skip to content

Instantly share code, notes, and snippets.

@kidd
Created March 10, 2010 21:59
-module (test3).
-export ([start/0 , f0/0]).
start () ->
Pid = spawn_link(test3,f0,[]),
loop (Pid).
loop (Pid) ->
Pid ! (string:strip(io:get_line ("msg: "),right, $\n)),
loop (Pid).
f0() ->
io:format ("~w~n", [self()]),
io:format ("0~n"),
receive
"hello" -> f1();
_ -> f0 ()
end.
f1 ()->
io:format ("1~n"),
receive
"converse" -> f2 ();
_ -> f1 ()
end.
f2 ()->
io:format ("2~n"),
receive
"goodbye" -> bye;
_ -> f2 ()
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment