changeset 78:75dbcd30dee5

Add final exercise code from Erlang It works, but it never made much sense because there was too much magic
author IBBoard <dev@ibboard.co.uk>
date Sat, 01 Jun 2019 20:10:37 +0100
parents 7bab4843aec6
children 29025305bbb7
files 5-Erlang/networked_client.erl 5-Erlang/networked_server.erl
diffstat 2 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/5-Erlang/networked_client.erl	Sat Jun 01 20:10:37 2019 +0100
@@ -0,0 +1,8 @@
+-module(networked_client).
+-export([translate/2]).
+
+translate(To, Word) ->
+    To ! { node(), Word },
+    receive
+        Translation -> io:format("~s~n", [Translation])
+    end.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/5-Erlang/networked_server.erl	Sat Jun 01 20:10:37 2019 +0100
@@ -0,0 +1,15 @@
+-module(networked_server).
+-export([loop/0]).
+
+loop() ->
+    receive
+        { Pid, "casa" } ->
+            Pid ! "house",
+            loop();
+        { Pid, "blanca" } ->
+            Pid ! "white",
+            loop();
+        { Pid, _ } ->
+            Pid ! "*blank stare*",
+            loop()
+end.
\ No newline at end of file