Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am Xdeon on github.
  • I am xdeon (https://keybase.io/xdeon) on keybase.
  • I have a public key whose fingerprint is ECA4 CC91 D0B1 BD10 F832 FADB F41A 5142 F9CE 9A54

To claim this, I am signing this object:

-module(first).
-export([double/1, mult/2, area/3, square/1, treble/1]).
mult(X, Y) ->
X * Y.
double(X) ->
mult(2, X).
-module(patterns).
-export([xOr1/2, xOr2/2, xOr3/2, xOr4/2, xOr5/2, maxThree/3, howManyEqual/3]).
xOr1(true, false) -> true;
xOr1(false, true) -> true;
xOr1(_, _) -> false.
xOr2(X, X) -> true;
xOr2(_, _) -> false.
-module(bits).
-export([bits/1, bits_tail/1]).
% Define a function bits/1 that takes a positive integer N and
% returns the sum of the bits in the binary representation.
% For example bits(7) is 3 and bits(8) is 1.
bits(0) ->
0;
-module(list1).
-export([product/1, product_tail/1, maximum/1, maximum_tail/1]).
product([]) -> 1;
product([X|Xs]) -> X*product(Xs).
product_tail(L) ->
product_tail(L, 1).
-module(list2).
-export([double/1, evens/1, median/1, modes/1]).
%% define an Erlang function double/1 to double the elements of a list of numbers.
double([]) -> [];
double([X|Xs]) -> [2*X|double(Xs)].
%% define a function evens/1 that extracts the even numbers from a list of integers.
evens([]) -> [];
-module(list3).
-export([take/2, nub/1, palindrome/1]).
-spec take(integer(), [T]) -> [T].
take(0, _) ->
[];
take(_, []) ->
[];
take(N, [X|Xs]) when N > 0 ->
-module(list4).
-export([join/2, concat/1, member/2, mergesort/1, quicksort/1, insertsort/1, perms/1]).
join(X, Y) -> lists:reverse(lists:reverse(X), Y).
concat([]) -> [];
concat([X|Xs]) -> join(X, concat(Xs)).
member(_, []) -> false;
-module(index).
-export([get_file_contents/1,show_file_contents/1, to_index_list/1, strip/1, nopunc/1]).
% Used to read a file into a list of lines.
% Example files available in:
% gettysburg-address.txt (short)
% dickens-christmas.txt (long)
% Get the contents of a text file into a list of lines.
The heat bloomed in December
as the carnival season
kicked into gear.
Nearly helpless with sun and glare, I avoided Rio's brilliant
sidewalks
and glittering beaches,
panting in dark corners
and waiting out the inverted southern summer.