%% Code from 
%%   Erlang Programming
      and  
    O'Reilly , 2008
%%   /
    /
    ( c )   and  

-module(modtest2). 
 
-export([main/0,loop/0,a/1,do/1]). 
 
main() -> 
  register(foo,spawn(modtest2,loop,[])). 

loop() -> 
  receive 
    {Sender, N} -> 
       Sender ! a(N) 
  end, 
  loop(). 
 
do(M) -> 
  foo ! {self(),M}, 
  receive Y -> 
    Y 
  end. 
 
a(N) -> N+2. 



 Code from 
   Erlang Programming
   /
      and  
    O'Reilly , 2008
    /
    ( c )   and  

-module(modtest2). 
 
-export([main/0,loop/0,a/1,do/1]). 
 
main() -> 
  register(foo,spawn(modtest2,loop,[])). 

loop() -> 
  receive 
    {Sender, N} -> 
       Sender ! a(N) 
  end, 
  loop(). 
 
do(M) -> 
  foo ! {self(),M}, 
  receive Y -> 
    Y 
  end. 
 
a(N) -> N+2. 


