Skip to content

Instantly share code, notes, and snippets.

-module(rps).
-export([result/2, tournament/2, test/0]).
-include_lib("eunit/include/eunit.hrl").
beat(rock) -> paper;
beat(paper) -> scissors;
beat(scissors) -> rock.
%% lose(rock) -> scissors;
%% lose(paper) -> rock;
-module(hof).
-export([
doubleAll/1,
events/1,
product/1,
zip/2,
zip_with/3
]).
doubleAll(L) ->
-module(list).
-export([join/2, concat/1, member/2, isort/1, msort/1, test/0]).
-include_lib("eunit/include/eunit.hrl").
join([], R) -> R;
join(L, []) -> L;
join(L, R) -> joinL(L, R).
joinL([H|[]], R) -> [H|R];
joinL([H|T], R) -> [H|joinL(T, R)].
-module(palindrome).
-export([pldm/1, test/0]).
-include_lib("eunit/include/eunit.hrl").
pldm(Str) ->
CStr = clean_string(Str),
Len = length(CStr),
pldm(CStr, [], Len div 2, 0, is_par(Len)).
pldm([H|_] = S1, S2, N, N, Par) ->
-module(list).
-export([ nub/1, nub_/1,test_nub/0, test_nub_/0]).
-include_lib("eunit/include/eunit.hrl").
%% remove all repeated elements except the first instance
nub(L) -> nub(L, []).
nub([], Acc) -> lists:reverse(Acc);
nub([El|Rest], Acc) ->
case lists:member(El, Acc) of
true -> nub(Rest, Acc);
-module(list).
-export([product/1, maximun/1, producT/1, maxT/1]).
%% ----------------
%% DIRECT RECURSION
%% ----------------
product([]) -> 1;
product([H|T]) -> H * product(T).
@calopez
calopez / dabblet.css
Last active September 2, 2016 01:19
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
html {font-size: 16px}
/*
Initially the css was very static:
padding: 6px 16px;
border: 1px solid #446d88;
background: #58a linear-gradient(#77a0bb, #58a);
border-radius: 4px;
@calopez
calopez / dabblet.html
Last active September 2, 2016 01:20
Untitled
<input type='text'/>
@calopez
calopez / README.md
Created May 31, 2016 12:44 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@calopez
calopez / install-emacs-centos.txt
Created November 23, 2015 16:17
How to install emacs 24.3 in CentOS 6
# su -
# yum install gcc make ncurses-devel
# yum install giflib-devel libjpeg-devel libtiff-devel
# cd /usr/local/src
# wget http://ftp.gnu.org/pub/gnu/emacs/emacs-24.3.tar.gz
# tar xzvf emacs-24.3.tar.gz
# cd emacs-24.3
# ./configure --without-x --without-selinux
# make
# make install