This file contains hidden or 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
| %%% 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) -> |
This file contains hidden or 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
| % 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]. |
This file contains hidden or 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
| % 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]. |
This file contains hidden or 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
| % 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([])), |
This file contains hidden or 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
| % 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(): |
This file contains hidden or 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
| % 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. | |
NewerOlder