Mercurial > repos > other > SevenLanguagesInSevenWeeks
view 5-Erlang/translate.erl @ 90:c27c87cd0f08
Add most of the Day 2 exercises for Haskell
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 16 Jun 2019 21:09:33 +0100 |
parents | 2df568aae515 |
children |
line wrap: on
line source
-module(translate). -export([loop/0]). % Invoke with: Pid = spawn(fun translate:loop/0). % Send messages with: Pid ! "message". % This is async with no return value. loop() -> receive % "receive" is a control structure that defines what "messages" we respond to "casa" -> io:format("house~n"), loop(); % And each entry must make sure that we start the loop again % If we had a "quit" message then it just wouldn't call loop() % Because of the way that tail recursion works then calling this last % has almost no overhead, but doing it in the middle would. "blanca" -> io:format("white~n"), loop(); _ -> io:format("*blank stare*~n"), loop() end.