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
#!/usr/bin/env node.sh | |
// Published under the MIT License - https://opensource.org/licenses/MIT | |
// Installation: | |
// 1 - Copy both node.sh and node.js in a directory included in your system PATH | |
// 2 - Ensure that both scripts are executable (chmod +x node.js node.sh) | |
// Usage: | |
// 1 - Invoke node.js in a terminal to start the shell | |
// 2 - Type .help to list the REPL commands available |
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
#! /bin/sh | |
# MIT License (https://opensource.org/licenses/MIT) | |
# Script to watch and reload Aqueduct (https://aqueduct.io/) on Mac OS. | |
# Requires fswatch (https://github.com/emcrisostomo/fswatch): brew install fswatch | |
# The server will automatically reload upon modification of dart files in lib directory | |
# To start development server: execute this script in an Aqueduct project folder. | |
# To quit: type CTRL+C in the terminal used to run the script. |
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(hh). | |
-export([ | |
doubleAll/1,doubleAllHH/1, | |
evens/1,evensHH/1, | |
product/1,productHH/1, | |
zip/2,zipT/2,zipHH/2, | |
zip_with/3,zip_withHH/3 | |
]). | |
-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(text). | |
-export([get_file_contents/1,print_text/2,process/2]). | |
-include_lib("eunit/include/eunit.hrl"). | |
%% ----------------------------------------------------------------------------- | |
%% Text Processing exercise from Functional Programming in Erlang 2.25 | |
%% ----------------------------------------------------------------------------- | |
%% Compiled and tested with Erlang/OTP 20.0 | |
%% ----------------------------------------------------------------------------- | |
%% To execute tests in the Erlang shell: |
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(consolidation). | |
-export([test_join/0,test_member/0,test_concat/0, | |
test_isort/0,test_msort/0,test_qsort/0, | |
test_perms/0, | |
concat/1,perms/1, | |
isort/1,msort/1,qsort/1, | |
insert/2,join/2,member/2]). | |
%% ----------------------------------------------------------------------------- | |
%% join |
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(pal). | |
-export([test/0,alpha_nums/1,palindrome/1]). | |
%% alph_nums filter outs punctuation or non printable characters. | |
alpha_nums([]) -> []; | |
alpha_nums([X|Xs]) when X >= $A andalso X =< $z -> | |
[X|alpha_nums(Xs)]; | |
alpha_nums([X|Xs]) when X >= $0 andalso X =< $9 -> | |
[X|alpha_nums(Xs)]; | |
alpha_nums([_|Xs]) -> |
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(nub). | |
-export([all_tests/0,nub/1,nub2/1]). | |
%% Helper to add element to list with no duplicate elements. | |
add(X, []) -> [X]; | |
add(X, [Y|Uniqs]) when X == Y -> [Y|Uniqs]; | |
add(X, [Y|Uniqs]) -> [Y|add(X, Uniqs)]. | |
%% Helper to create a list of unique elements. | |
uniqs([],Uniqs) -> Uniqs; |
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(more_lists). | |
-export([reverse/1,take/2,take2/2,test_take/0,test_take2/0]). | |
%% Take with direct recursion | |
-spec take(integer(), [T]) -> [T]. | |
take(_, []) -> []; % handles case where N > length(Xs) | |
take(0, _) -> []; | |
take(N, [X|Xs]) when N > 0 -> [X | take(N-1, Xs)]. | |
test_take() -> |
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(transform). | |
-export([double/1,evens/1,median/1,modes/1,sort/1,counters/2]). | |
%% ---------------------------------------------------------------------------- | |
%% Double | |
double([]) -> []; | |
double([X|Xs]) -> [2*X | double(Xs)]. | |
%% ---------------------------------------------------------------------------- | |
%% Evens |
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(product). | |
-export([all_tests/0,test_sum/0,test_prod/0,test_maximum/0,sum/1,sumT/1,prod/1, | |
prodT/1,maximum/1,maximumT/1]). | |
%% sum implementation with direct recursion (per the video) | |
sum([]) -> 0; | |
sum([X|Xs]) -> X + sum(Xs). | |
%% sum implementation with tail recursion (per the video) | |
sumT(Xs) -> sumT(Xs, 0). |
NewerOlder