From ed7f050a0f6d008b327098ad930c4873d3b3e461 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 13 Oct 2010 11:52:54 +0200 Subject: changed repository layout --- calc/remote.erl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 calc/remote.erl (limited to 'calc/remote.erl') diff --git a/calc/remote.erl b/calc/remote.erl new file mode 100644 index 0000000..793c27c --- /dev/null +++ b/calc/remote.erl @@ -0,0 +1,22 @@ +-module(remote). +-export([start/0, calculate/1]). + +rpc(C) -> + rechner ! {self(), C}, + receive + {rechner, Reply} -> + Reply + end. + +loop() -> + receive + {From, {calculate, String}} -> + From ! {rechner, calc:eval(String)}, + loop() + end. + +start() -> + register(rechner, spawn(fun() -> loop() end)). + +calculate(String) -> + rpc({calculate, String}). -- cgit v1.2.3