diff options
Diffstat (limited to 'learn-you-some-erlang/dolphins.erl')
-rw-r--r-- | learn-you-some-erlang/dolphins.erl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/learn-you-some-erlang/dolphins.erl b/learn-you-some-erlang/dolphins.erl new file mode 100644 index 0000000..1e84b77 --- /dev/null +++ b/learn-you-some-erlang/dolphins.erl @@ -0,0 +1,34 @@ +-module(dolphins). +-compile(export_all). + +dolphin1() -> + receive + do_a_flip -> + io:format("How about no?~n"); + fish -> + io:format("So long and thanks for all the fish!~n"); + _ -> + io:format("Heh, we're smarter than you humans.~n") + end. + +dolphin2() -> + receive + {From, do_a_flip} -> + From ! "How about no?"; + {From, fish} -> + From ! "So long and thanks for all the fish!"; + _ -> + io:format("Heh, we're smarter than you humans.~n") + end. + +dolphin3() -> + receive + {From, do_a_flip} -> + From ! "How about no?", + dolphin3(); + {From, fish} -> + From ! "So long and thanks for all the fish!"; + _ -> + io:format("Heh, we're smarter than you humans.~n"), + dolphin3() + end. |