Skip to content

Instantly share code, notes, and snippets.

@50kudos
Last active February 21, 2017 01:48
Show Gist options
  • Save 50kudos/09df656b961b9c1ef0892472219c0529 to your computer and use it in GitHub Desktop.
Save 50kudos/09df656b961b9c1ef0892472219c0529 to your computer and use it in GitHub Desktop.
-module(third).
-export([maxThree/3,howManyEqual/3,eXOR/2]).
eXOR(X,Y) when is_boolean(X) andalso is_boolean(Y) ->
case {X,Y} of
{Y,X} -> false;
_ -> true
end.
maxThree(A,B,C) when is_integer(A) andalso is_integer(B) andalso is_integer(C) ->
max(max(A,B),C).
howManyEqual(A,B,C) when is_integer(A) andalso is_integer(B) andalso is_integer(C) ->
case {A,B,C} of
{_,A,A} -> 3;
{B,A,_} -> 2;
{C,_,A} -> 2;
{_,C,B} -> 2;
{_,_,_} -> 0
end.
@50kudos
Copy link
Author

50kudos commented Feb 21, 2017

@hgisinger Thanks for sharing. I was aware of using functions matching but I felt guilty for defining the same 4+ functions' name. :octocat:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment