view 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
line wrap: on
line source

-module(matching_function).
-export([number/1]).

% Like Prolog, we can define different function matches as "overrides" of the function
% with the same name/parameter count but different "fixed" values
% For some reason these are separated by semi-colons here
number(one) -> 1;
number(two) -> 2;
number(three) -> 3.

% Calling this with any value or atom other than one, two or three will fail.