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(mailbox). | |
-export([start_receiver/0, start_receiver_stop/0, start_selective_receiver/0, receiver/0, receiver_stop/0, selective_receiver/0]). | |
start_receiver() -> | |
spawn(?MODULE, receiver, []). | |
start_receiver_stop() -> | |
spawn(?MODULE, receiver_stop, []). | |
start_selective_receiver() -> |
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(palindrome_server). | |
-export([start_server/0, | |
start_servers/1, | |
start_balancer/1, | |
stop_server/1, | |
stop_servers/1, | |
stop_balancer/1, | |
check/2, | |
balancer/1, | |
server/0, |
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([play/1, | |
echo/1, | |
play_two/3, | |
rock/1, | |
no_repeat/1, | |
least_freq/1, | |
most_freq/1, | |
const/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(hof2). | |
-export([add/1, times/1, compose/2, list_compose/1, twice/1, iterate/1]). | |
add(X) -> | |
fun(Y) -> X+Y end. | |
times(X) -> | |
fun(Y) -> | |
X*Y end. |
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([doubleAll/1, evens/1, product/1, zip/2, zip_with/3, zip_with_hof/3, zip_hof/2]). | |
doubleAll(L) -> | |
lists:map(fun(X) -> 2*X end, L). | |
evens(L) -> | |
lists:filter(fun(X) -> X rem 2 == 0 end, L). |
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(supermarket). | |
-export([test_database/0, find_item/2, update_item/2, remove_item/2, shop/2, shop/3, bill/3]). | |
-type database() :: [entry()]. | |
-type entry() :: {barcode(), item(), price()}. | |
-type barcode() :: integer(). | |
-type item() :: string(). | |
-type price() :: integer(). | |
-type bill() :: [{string(), integer()}]. |
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
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. |
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([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. |
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(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; |
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(list3). | |
-export([take/2, nub/1, palindrome/1]). | |
-spec take(integer(), [T]) -> [T]. | |
take(0, _) -> | |
[]; | |
take(_, []) -> | |
[]; | |
take(N, [X|Xs]) when N > 0 -> |