Created
February 26, 2017 11:40
-
-
Save ubaldop/9796cd36e0d535f05e779acef4cc487c to your computer and use it in GitHub Desktop.
Second homework solution, 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
-module(pattern_matching). | |
-export([exclusiveOr/2,exclusiveOr2/2,exclusiveOr3/2, maxThree/3, howManyEquals/3]). | |
exclusiveOr(X,Y) -> | |
not(X==Y). | |
exclusiveOr2(X,Y) -> | |
(X=/=Y). | |
exclusiveOr3(X,Y) when (X and Y) -> false; | |
exclusiveOr3(X,Y) when not (X or Y) -> false; | |
exclusiveOr3(_,_) -> true. | |
maxThree(X,Y,Z) when ((X > Z) or (Y > Z)) -> max(X,Y); | |
maxThree(_,_,Z) -> Z. | |
howManyEquals(X,X,X) -> 3; | |
howManyEquals(X,Y,Z) when (X == Y) or (X == Z) or (Y == Z) -> 2; | |
howManyEquals(_,_,_) -> 0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment