Skip to content

Instantly share code, notes, and snippets.

View paucus's full-sized avatar

Marcelo Ruiz Camauër paucus

  • Buenos Aires, Argentina
View GitHub Profile
@paucus
paucus / 1.15 sample run.txt
Created April 12, 2017 12:15
sample run of frequency server, revised, assignment 1.15 second course.
{ok,frequency}
10> frequency:start().
server_already_running
11> frequency:clear().
Client: done clearing messages.
ok
12> frequency:deallocate(10).
Client: server took too long to deallocate my frequency.
ok
13> frequency:deallocate(10).
@paucus
paucus / frequency2.erl
Last active April 12, 2017 12:13
revised frequency, assignment 1.15
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
%% Step 1.15 ASSIGNMENT: Enhancing the frequency server
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([init/0,start/0,stop/0,test_functions/0]).
@paucus
paucus / b180.erl
Created April 5, 2017 16:11
testing mailboxes
%%% assignment 1.50 palindrome checker process
-module(b180).
-export([start/0,receiver/0,seqreceiver/0]).
%-include_lib("eunit/include/eunit.hrl").
-created_by("Marcelo Ruiz Camauër").
start()->
Pid = spawn(?MODULE,receiver,[]),
@paucus
paucus / b150.erl
Created April 4, 2017 14:38
palindrome server
%%% assignment 1.50 palindrome checker process
-module(b150).
-export([start/0,server/0,palindrome/1]).
-include_lib("eunit/include/eunit.hrl").
-created_by("Marcelo Ruiz Camauër").
% Define a function server/1 that accepts messages of the form
%
% {check,"Madam I\'m Adam"}
@paucus
paucus / rps.erl
Last active March 20, 2017 19:30
%%% assignment 3.12 Functional Programming in Erlang, 2017
-module(rps).
-export([play/1,echo/1,play_two/3,rock/1,no_repeat/1,const/1,enum/1,cycle/1,rand/1,val/1,tournament/2]).
-export([type_count/1, least_freq_played/1,most_freq_played/1,rand_strategy/1]).
-created_by("Marcelo Ruiz Camauër").
-include_lib("eunit/include/eunit.hrl").
-module(a35).
-export([doubleAll/1, evens/1, product/1,zip/2,zip_with/3,zip_with_map/3,zip_with_zip_with/2]).
-include_lib("eunit/include/eunit.hrl").
-created_by("Marcelo Ruiz Camauër").
%%% invoke with:
%%% a35:test().
%%% higher order functions
-module(index).
-export([index_file/1]).
readlines(Name) ->
{ok,File} = file:open(Name,[read]),
extract_content(File,[]).
extract_content(File,Partial) ->
case io:get_line(File,"") of
eof -> file:close(File), Partial;
%%% assignment 2.20
% Indexing a file
% The aim of this exercise is to index a text file, by line number.
% We can think of the input being a list of text strings, and below we’ve provided an outline Erlang
% module that reads text files into this format, as well as a couple of example files to process.
% The output of the main function should be a list of entries consisting of a word
% and a list of the ranges of lines on which it occurs.
%
% For example, the entry
%%% assignment 2.15 palindromes
-module(a215).
-include_lib("eunit/include/eunit.hrl").
-created_by("Marcelo Ruiz Camauër").
-export([palindrome/1]).
-export([remove_punctuation/2]).
-spec palindrome(list()) -> boolean().