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
-module(mailbox). | |
-export([start/0,proccess/0,proccess2/0]). | |
start() -> | |
spawn(mailbox,proccess,[]). | |
proccess() -> | |
timer:sleep(3000), | |
receive | |
stop -> ok; |
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
-module(palindrome). | |
-export([server/1]). | |
rem_punct(String) -> lists:filter(fun (Ch) -> | |
not(lists:member(Ch,"\"\'\t\n ")) | |
end, | |
String). |
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
-module(rps). | |
-export([tournament/2]). | |
beat(rock) -> paper; | |
beat(paper) -> scissors; | |
beat(scissors) -> rock. | |
result({X,X},Acc) -> Acc; |
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
-module(format). | |
-export([text_processing/3]). | |
% Used to read a file into a list of lines. | |
% Example files available in: | |
% gettysburg-address.txt (short) | |
% dickens-christmas.txt (long) | |
% Get the contents of a text file into a list of lines. | |
% Each line has its trailing newline removed. |
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
-module(index). | |
-export([get_file_contents/1,show_file_contents/1,index_words/1,test/0]). | |
% Used to read a file into a list of lines. | |
% Example files available in: | |
% gettysburg-address.txt (short) | |
% dickens-christmas.txt (long) | |
% Get the contents of a text file into a list of lines. | |
% Each line has its trailing newline removed. |
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
-module(nub). | |
-export([test/0,nub/1]). | |
-spec nub(list()) -> list(). | |
nub(L) -> nub(L,[]). | |
%Adds non repeated elements to the list. | |
-spec nub(list(),list()) -> list(). |
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
-module(take). | |
-export([take/2]). | |
-spec take(integer(),list()) -> list(). | |
take(X,L) -> take(X,L,[]). | |
-spec take(integer(),list(),list()) -> list(). | |
take(_,[],Acc) -> lists:reverse(Acc); | |
take(0,_,Acc) -> lists:reverse(Acc); |
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
-module(constructing_lists). | |
-export([double/1,evens/1,test/0,median/1,modes/1]). | |
%double function start here. | |
double(L) -> double(L,[]). | |
double([],Acc) -> | |
reverse(Acc,[]); | |
double([H|T],Acc) -> |
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
-module(w2lists). | |
-export([prod/1,mymax/1,test/0]). | |
%Moddified according Elbrujohalcon: | |
%Removed the "list is emty" function clause as we will let it crash. | |
%prod([]) -> | |
% "list is empty"; | |
prod([H|T]) -> | |
prod(T,H). |
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
-module(pat). | |
-export([perimeter/1,area/1,enclosure/1,bits/1,bits_rec/1,tests/0]). | |
%Shapes exercises | |
%I considered not necessary to validate the shapes as john don't use it during his examples, | |
% forexp in circle R > 0 and in triangle A + B > C,etc.. | |
perimeter({circle,_,Radius}) -> | |
2 * math:pi() * Radius; |
NewerOlder