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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 -module(matching_function).
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 -export([number/1]).
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 % Like Prolog, we can define different function matches as "overrides" of the function
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 % with the same name/parameter count but different "fixed" values
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 % For some reason these are separated by semi-colons here
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 number(one) -> 1;
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 number(two) -> 2;
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 number(three) -> 3.
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
32f018861e36 Add Day 1 Erlang content
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 % Calling this with any value or atom other than one, two or three will fail.