Skip to content

Instantly share code, notes, and snippets.

-module(rps2).
-export([
play/1,
echo/1,
play_two/3,
rock/1,
no_repeat/1,
const/1,
least_frequent/1,
more_frequent/1,
-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).
-module(rps).
-export([
beat/1,
lose/1,
result/2,
tournament/2
]).
-include_lib("eunit/include/eunit.hrl").
-module(bill).
-export([
database/0,
bill/0,
print_bill/1
]).
database() -> [
{4719, "Fish Fingers" , 121},
{5643, "Nappies" , 1010},
-module(process).
-export([
process_file/2,
show_lines/1
]).
%%
%% show_lines(LineList) -> ok
%%
%% Print out the Lines
-module(index).
-export([
process_file/2
]).
%%
%% process_file(InputFile, OutputFile) -> Index
%%
%% this funcion does the next:
%% a) reads a text form the file InputFile
-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
%%
-module(lst).
-export([
take/2,
]).
%%
%% take(N, L) -> returns the N first elements of the list L
%%
take(0, _L) -> [];
take(_N, []) -> [];
-module(lst).
-export([
take/2,
reverse/1,
palindrome/1,
remove/2,
nub/1
]).
%%
-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).
%%