area_server2.erl
area_server2.erl — 1 KB
Continguts del fitxer
-module(area_server2). -export([loop/0, rpc/2]). rpc(Pid, Peticio) -> Pid ! {self(), Peticio}, receive Resposta -> %io:format("Peticio = ~p~n",[Peticio]), %{Fig,_} = Peticio, Fig=element(1,Peticio), io:format("L'rea del ~p s de ~p.~n", [Fig,Resposta]) end. loop() -> receive {From, {rectangle, X, Y}} -> From ! X * Y, loop(); {From, {cercle, R}} -> From ! 3.14159 * R * R, loop(); {From, Other} -> From ! {error,Other}, loop() end.