Moved Life implementations into 'life' directory.
[cellular-automata.git] / life / 001 / src / life_lib.erl
diff --git a/life/001/src/life_lib.erl b/life/001/src/life_lib.erl
new file mode 100644 (file)
index 0000000..3b26b08
--- /dev/null
@@ -0,0 +1,20 @@
+-module(life_lib).
+
+-export([cast_one2all/2
+        ,cast_all2one/2
+        ]).
+
+
+% Cast all messages to one destination
+cast_all2one(_, []) -> ok;
+cast_all2one(Server, [Msg | Msgs]) ->
+    ok = gen_server:cast(Server, Msg),
+    cast_all2one(Server, Msgs).
+
+
+% Cast one message to all destinations
+cast_one2all([], _) -> ok;
+cast_one2all([Server | Servers], Msg) ->
+    ok = gen_server:cast(Server, Msg),
+    cast_one2all(Servers, Msg).
+
This page took 0.025626 seconds and 4 git commands to generate.