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([fac/1,fib/1,pieces/1,pieces_n_dimentions/2]). | |
| %Factorial | |
| fac(0) -> | |
| 1; | |
| fac(N) when N>0 -> | |
| fac(N-1)*N; | |
| fac(_) -> | |
| 'error'. |
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(how_many_equal). | |
| -export([howManyEqual/3]). | |
| equal(X,X,X) -> | |
| 3; | |
| equal(_,X,X) -> | |
| 2; | |
| equal(X,X,_) -> | |
| 2; | |
| equal(X,_,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(maximum_of_three). | |
| -export([max_three/3]). | |
| max_three(X,Y,Z) -> | |
| max(max(X, Y),Z). |
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(exclusive_or). | |
| -export([xor_1/2,xor_2/2,xor_3/2]). | |
| %Testing with numbers and boolean values as well. | |
| xor_1(X,Y) -> | |
| (X=/=Y) or | |
| false. | |
| xor_2(X,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
| -module(second). | |
| -export([hypotenuse/2,hypotenuseMethod2/2,area4RightAngleTriangle/2,perimeter4RightAngleTriangle/3]). | |
| hypotenuse(X,Y) -> | |
| % hypotenuse of a right-angled triangle | |
| A = first:squareNumber(X), | |
| B = first:squareNumber(Y), | |
| math:sqrt(A+B). | |
| hypotenuseMethod2(X,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
| -module(first). | |
| -export([double/1,mult/2,area/3,squareNumber/1,trebleNumber/1]). | |
| mult(X,Y) -> | |
| X*Y. | |
| double(X) -> | |
| mult(2,X). | |
| area(A,B,C) -> |