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
<?php | |
// See https://benramsey.com/projects/ramsey-uuid/ | |
// Install ramsey/uuid through composer and use the following snippet: | |
require 'vendor/autoload.php'; | |
use Ramsey\Uuid\Uuid; | |
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; | |
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(first). | |
-export([double/1,treble/1,square/1,mult/2,area/3]). | |
mult(X,Y) -> | |
X*Y. | |
double(X) -> | |
mult(2,X). | |
treble(X) -> |
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(third). | |
-export([xOr_1/2, xOr_2/2, xOr_3/2, maxThree/3, howManyEqual/3]). | |
% XOR implementation #1 | |
xOr_1(A,A) -> | |
false; | |
xOr_1(A,B) -> | |
A or B. | |
% XOR implementation #2 |
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(recursion). | |
-export([fib/1,fibTail/1,pieces/2]). | |
-export([fibTest/0,fibTailTest/0,piecesTest/0]). | |
% Fibonaaci | |
fib(0) -> 0; | |
fib(1) -> 1; | |
fib(N) when N>1 -> | |
fib(N-2) + fib(N-1). |
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(tail_recursion). | |
-export([fib/1,perfect/1]). | |
-export([fibTest/0,perfectTest/0]). | |
% Tail recursive fibonacci | |
fib(N) -> fib(N, 0, 1). | |
fib(0, A, _) -> A; | |
fib(N, A, B) -> fib(N-1, A+B, A). | |
fibTest() -> |
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(assignment). | |
-export([bits/1,distance/2,perimeter/1,area/1]). | |
-export([bitsTest/0,perimeterTest/0,areaTest/0]). | |
% Bits %%% | |
%% Exposed bit counter function | |
bits(N) -> bits(N, 0). |
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(list_functions). | |
-export([product/1,maximum/1,product_notail/1,maximum_notail/1]). | |
-export([product_test/0,maximum_test/0,product_notail_test/0,maximum_notail_test/0]). | |
%% Product %%% | |
product([]) -> 1; | |
product([A|B]) -> product([A|B], 1). | |
product([], P) -> P; |
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]). | |
-export([take_test/0]). | |
-spec take(integer(), [T]) -> [T]. | |
take(_, []) -> []; | |
take(0, _) -> []; | |
take(N, L) -> take(N, L, []). | |
take(_, [], Ac) -> lists:reverse(Ac); |
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(list_functions2). | |
-export([double/1,evens/1]). | |
-export([double_test/0,evens_test/0]). | |
%% double %%% | |
double([]) -> []; | |
double([_|_] = L) -> double(L, []). | |
double([], Ac) -> lists:reverse(Ac); |
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([nub/1]). | |
-export([nub_test/0]). | |
nub([]) -> []; | |
nub([_|_] = L) -> nub(L, []). | |
nub([], Ac) -> lists:reverse(Ac); | |
nub([H|T], Ac) -> | |
case lists:member(H, Ac) of |
OlderNewer