Inspirado no repto lançado pela Adobe, deixo os meus votos para o ano de 2009 em 26 linhas de pura concorrência ;)
-module(newYear).
-export([start/0,newLife/0,happiness/0,health/1,work/0]).
start() -> spawn(newYear,newLife,[]).
newLife() -> spawn(newYear,happiness,[]).
happiness() ->
WorkPid = spawn(newYear,work,[]),
HealthPid = spawn(newYear,health,[WorkPid]),
HealthPid ! go.
health(WorkPid) ->
receive
go ->
io:format("Healthy..."),
WorkPid ! {self(),go},
health(WorkPid);
ill ->
io:format("I'm ill..."),
WorkPid ! {self(),stop}
end.
work() ->
receive
{HealthPid,go} ->
io:fwrite(" and working~n"),
HealthPid ! go,
work();
stop -> io:format(" so I'll stop working!~n")
end.
Temas
acessibilidade apache apple blues browser centos chrome css dbms educação empreendedorismo emprego erlang Extreme Programming Firefox flash forum google governo html iBook javascript jazz linux microsoft mysql música OpenOffice.org OWASP php poesia Porto programação SAF-T PT scootzz segurança sgbd software spam sql standard telemóvel ubuntu w3c webCategorias
Arquivo
