view 5-Erlang/matching_function.erl @ 74:41c7cd909218

Write up exercises for Erlang day 2 (including bonus Tic Tac Toe)
author IBBoard <dev@ibboard.co.uk>
date Sat, 03 Feb 2018 19:53:28 +0000
parents 32f018861e36
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.