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(rps2). | |
-export([ | |
play/1, | |
echo/1, | |
play_two/3, | |
rock/1, | |
no_repeat/1, | |
const/1, | |
least_frequent/1, | |
more_frequent/1, |
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(hof). | |
-export([compose/1, twice/1, add/1, times/1, compose/2, id/1, iterate/1]). | |
-include_lib("eunit/include/eunit.hrl"). | |
%% | |
%% compose | |
%% | |
-spec compose([function()]) -> function(). | |
compose(Fs) -> | |
lists:foldr(fun compose/2, fun id/1, Fs). |
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(rps). | |
-export([ | |
beat/1, | |
lose/1, | |
result/2, | |
tournament/2 | |
]). | |
-include_lib("eunit/include/eunit.hrl"). |
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(bill). | |
-export([ | |
database/0, | |
bill/0, | |
print_bill/1 | |
]). | |
database() -> [ | |
{4719, "Fish Fingers" , 121}, | |
{5643, "Nappies" , 1010}, |
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(process). | |
-export([ | |
process_file/2, | |
show_lines/1 | |
]). | |
%% | |
%% show_lines(LineList) -> ok | |
%% | |
%% Print out the Lines |
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(index). | |
-export([ | |
process_file/2 | |
]). | |
%% | |
%% process_file(InputFile, OutputFile) -> Index | |
%% | |
%% this funcion does the next: | |
%% a) reads a text form the file InputFile |
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(comb). | |
-export([permutations/1]). | |
%% | |
%% permutations(L): generates a list with all the permutations of the elements of the list. | |
%% | |
%% For each element in the list: | |
%% a) combine this element with the permutations of the rest of the list. | |
%% b) store the results | |
%% |
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(lst). | |
-export([ | |
take/2, | |
]). | |
%% | |
%% take(N, L) -> returns the N first elements of the list L | |
%% | |
take(0, _L) -> []; | |
take(_N, []) -> []; |
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(lst). | |
-export([ | |
take/2, | |
reverse/1, | |
palindrome/1, | |
remove/2, | |
nub/1 | |
]). | |
%% |
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(lst). | |
-export([sum/1, product/1, maximum/1, double/1, events/1, median/1, modes/1]). | |
%% | |
%% sum | |
%% | |
sum([]) -> 0; | |
sum([X|XS]) -> X + sum(XS). | |
%% |