Created
February 25, 2017 07:00
-
-
Save javajosh/a6dfd0e307a76326236b6d42091bb2c4 to your computer and use it in GitHub Desktop.
An exercise for the Future Learn Erlang course.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%------------------------------------------------------------------- | |
%%% @author josh | |
%%% @copyright (C) 2017, <COMPANY> | |
%%% @doc | |
%%% | |
%%% @end | |
%%% Created : 24. Feb 2017 10:36 PM | |
%%%------------------------------------------------------------------- | |
-module(third). | |
-author("josh"). | |
%% API | |
-export([xOr1/2, xOr2/2, xOr3/2, xOr4/2, maxThree/3, howManyEqual/3]). | |
xOr1(X,Y) -> | |
X =/= Y. | |
xOr2(X,Y) -> | |
not (X == Y). | |
xOr3(X,Y) -> | |
X and not Y. | |
xOr4(false, false) -> | |
false; | |
xOr4(false, true) -> | |
true; | |
xOr4(true, false) -> | |
true; | |
xOr4(true, true) -> | |
false. | |
maxThree(X,Y,Z) -> | |
A = max(X,Y), | |
max(A,Z). | |
howManyEqual(X,X,X) -> | |
3; | |
howManyEqual(X,X,_) -> | |
2; | |
howManyEqual(_,X,X) -> | |
2; | |
howManyEqual(X,_,X) -> | |
2; | |
howManyEqual(_,_,_) -> | |
0. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment