Skip to content

Instantly share code, notes, and snippets.

@javajosh
Created February 25, 2017 07:00
Show Gist options
  • Save javajosh/a6dfd0e307a76326236b6d42091bb2c4 to your computer and use it in GitHub Desktop.
Save javajosh/a6dfd0e307a76326236b6d42091bb2c4 to your computer and use it in GitHub Desktop.
An exercise for the Future Learn Erlang course.
%%%-------------------------------------------------------------------
%%% @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