fork download
  1. -module(prog).
  2. -export([main/0]).
  3.  
  4. loop() ->
  5. receive
  6. {greet, Name} -> io:format("Hello, ~s!~n", [Name]);
  7. {offend, Name} -> io:format("You're an ass-cactus, ~s!~n", [Name])
  8. end,
  9. loop().
  10.  
  11. main() ->
  12. Pid = spawn(fun() -> loop() end),
  13. %% ! is the send operator
  14. Pid ! { greet, "rightfold" },
  15. Pid ! { offend, "Telkitty" },
  16. timer:sleep(1000),
  17. true.
  18.  
Success #stdin #stdout 0.2s 23456KB
stdin
Standard input is empty
stdout
Hello, rightfold!
You're an ass-cactus, Telkitty!