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 / a213.erl
Created March 6, 2017 21:53
Assignment 2.13
%%% assignment 2.13
-module(a213).
-include_lib("eunit/include/eunit.hrl").
-created_by("Marcelo Ruiz Camauër").
-export([nub/1]).
%% contains() copied from Jeremiah B.:
contains([], _Y) ->
@paucus
paucus / a211.erl
Created March 5, 2017 22:49
assignment 2.11
% Marcelo Ruiz Camauër
% assignment 2.11
% Define a function take that takes the first N elements from a list.
-module(a211).
-export([take/2]).
-include_lib("eunit/include/eunit.hrl").
-spec take(integer(),[L]) -> [L].
@paucus
paucus / a29.erl
Created March 5, 2017 21:59
assignment 2.9
% Marcelo Ruiz Camauër
% assignment 2.9
-module(a29).
-export([double/1,evens/1, median/1]).
-include_lib("eunit/include/eunit.hrl").
%Define an Erlang function double/1 to double the elements of a list of numbers
double([])->[];
double(L) -> [Value * 2 || Value <- L].
% Marcelo Ruiz Camauër
% assignment 2.6 a26_tests
% invoke with 'a26_tests:test().'
-module(a26_tests).
-include_lib("eunit/include/eunit.hrl").
listprod_test()->
?assertEqual(1,a26:listprod([])),
% Marcelo Ruiz Camauër
% assignment 2.6
-module(a26).
-export([listprod/1,listprod2/1,listmax/1,listmax2/1]).
% define an Erlang function to give the product of a list of numbers.
% The product of an empty list is usually taken to be 1
% recursive listprod():
% Marcelo Ruiz-Camauër
% Introduction to Erlang assignment 1.24
% Feb. 2017
%
% Shapes:
% Define a function perimeter/1 which takes a shape and returns the perimeter of the shape.
% Choose a suitable representation of triangles, and augment area/1 and perimeter/1 to handle this case too.
% Define a function enclose/1 that takes a shape an returns the smallest enclosing rectangle of the shape.