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(hof). | |
-author("@sgobotta"). | |
-include_lib("eunit/include/eunit.hrl"). | |
-export([doubleAll/1, evens/1, product/1]). | |
-export([zip/2, zip_using_hof/2]). | |
-export([zip_with/3, zip_with_using_hof/3]). | |
%% Define the functions doubleAll, evens, and product using the higher-order | |
%% functions lists:map, lists:filter and lists:foldr. | |
%% |
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(bill). | |
-author("@sgobotta"). | |
-export([barcodes/0, main/1]). | |
-include_lib("eunit/include/eunit.hrl"). | |
-type item_code() :: integer(). | |
-type item_name() :: string(). | |
-type item_price() :: integer(). | |
-type item() :: {item_code(), item_name(), item_price()}. | |
-type item_maybe() :: nothing | {just, item()}. |
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(txt). | |
-author("@sgobotta"). | |
-include_lib("eunit/include/eunit.hrl"). | |
-export([ | |
get_file_contents/1, | |
format/3, | |
main/2 | |
]). | |
%% @doc Given a command and a line length, reads the text.txt file to output |
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(ex). | |
-author("@sgobotta"). | |
-export([ | |
take/2, test_take/0, | |
nub/1, test_nub/0, | |
contains/2, test_contains/0, | |
palindrome/1, test_palindrome/0 | |
]). | |
%% @doc Given a number N and a list, takes the first N elements from the list |
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(list). | |
-author("@sgobotta"). | |
-export([ | |
double_dr/1, test_double_dr/0, | |
double_tr/1, test_double_tr/0, | |
evens_dr/1, test_evens_dr/0, | |
evens_tr/1, test_evens_tr/0, | |
median/1, test_median/0, | |
maximum_dr/1, test_maximum_dr/0, | |
maximum_tr/1, test_maximum_tr/0, |
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(list). | |
-export([ | |
product_dr/1, test_product_dr/0, | |
product_tr/1, test_product_tr/0, | |
maximum_dr/1, test_maximum_dr/0, | |
maximum_tr/1, test_maximum_tr/0 | |
]). | |
%% @doc Given a list of numbers returns the product of it's elements. | |
%% The case base should return 1 since it's the neutral element of the |
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(recursion). | |
-export([ | |
fib/1, | |
test_fib/0, | |
is_perfect_number/1, | |
test_is_perfect_number/0 | |
]). | |
fib(N) -> fib(N,0,1). |
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(recursion). | |
-export([fib/1, fibs/1, pieces/1]). | |
%% @doc given an integer computes it's position in the fibonacci sequence | |
fib(0) -> 0; | |
fib(1) -> 1; | |
fib(X) -> fib(X-1) + fib(X-2). | |
%% @doc given a fibonacci sequence position returns the sum of fibonacci computations | |
fibs(X) -> 1 + 1 + fibs(X-1) + fibs(X-2). |
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
% @doc Pattern Mathing module for the 1.15 step of the FutureLearn Erlang Course. | |
-module(pattern_matching). | |
-export([ | |
xOr/2, | |
xOr1/2, | |
xOr2/2, | |
xOr3/2, | |
xOr4/2, | |
max_three/3, |
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(first). | |
-export([ | |
double/1, | |
mult/2, | |
area/3, | |
square/1, | |
trbl/1, | |
sum/3 | |
]). |