Last active
May 12, 2020 03:21
-
-
Save tambow44/4176b709d7184f844a47239af3dc48d5 to your computer and use it in GitHub Desktop.
This file contains 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(third). | |
-export([xor_1/2,xor_2/2,xor_3/2,max_three/3,how_many_equal/3]). | |
% '=/=' and '==' are the operations for inequality and equality in Erlang | |
xor_1(X,Y) -> | |
(X =/= Y) | |
. | |
% 'not' is the Erlang negation function | |
xor_2(X,Y) -> | |
not (X == Y) | |
. | |
% 'and' and 'or' are the Erlang conjunction and disjunction (infix) operators. | |
xor_3(X,Y) -> | |
(X =/= Y) and (X or Y) | |
. | |
max_three(X,Y,Z) -> | |
max(max(X, Y), Z) | |
. | |
% I had to peek for howManyEqual | |
% Don't know enough of Erlang to do any "smart" logic | |
% Specifically how to get stacks working | |
how_many_equal(X,X,X) -> 3; | |
how_many_equal(X,_,X) -> 2; | |
how_many_equal(X,X,_) -> 2; | |
how_many_equal(_,X,X) -> 2; | |
how_many_equal(_,_,_) -> 0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment