Mercurial > repos > other > SevenLanguagesInSevenWeeks
annotate 5-Erlang/matching_function.erl @ 71:32f018861e36
Add Day 1 Erlang content
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 02 Feb 2018 20:38:36 +0000 |
parents | |
children |
rev | line source |
---|---|
71 | 1 -module(matching_function). |
2 -export([number/1]). | |
3 | |
4 % Like Prolog, we can define different function matches as "overrides" of the function | |
5 % with the same name/parameter count but different "fixed" values | |
6 % For some reason these are separated by semi-colons here | |
7 number(one) -> 1; | |
8 number(two) -> 2; | |
9 number(three) -> 3. | |
10 | |
11 % Calling this with any value or atom other than one, two or three will fail. |