fac(N) when N>0 -> N * fac(N-1); fac(0) -> 1.
Echo = spawn(echo,loop,[]), Echo ! {self(),"Here is a message"}, .... loop() -> receive {From,Msg} -> From ! Msg, loop() end.
Echo = spawn(SomeNode,echo,loop,[]), ....
-module(bankserver). -export([start/1]). start(Sum) -> register(bank,self()), account(Sum). account(Sum) -> receive {Pid, Ref, Amount} -> NewSum = Sum+Amount, Pid ! {Ref,NewSum}, account(NewSum); stop -> nil end.
% spawn a bank account process with initial Sum 1000 Bank_pid = spawn(BankNode,bankserver,start,[1000]), ... Ref = make_ref(), Bank_pid ! {self(),Ref,17}, receive {Ref,New_balance} -> ... end,