Created
May 5, 2020 19:34
-
-
Save danielribes/4b13c28b3d1b3da8eccdfc16cb9cc03e to your computer and use it in GitHub Desktop.
Functional Programming in Erlang The University of Kent - Activity 1.9, second module
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
%% | |
%% second.erl | |
%% - Functional Programming in Erlang | |
%% Activity 1.9 | |
%% | |
%% Daniel Ribes | |
%% | |
-module(second). | |
-export([hypotenuse/2, perimeter/2, perimeter/3, area/2]). | |
%% | |
%% Hypotenuse of a right-angled triangle | |
%% | |
hypotenuse(A, B) -> | |
H = first:square(A) + first:square(B), | |
math:sqrt(H). | |
%% | |
%% Area of a right-angled triangle | |
%% | |
area(A, B) -> | |
B * A / 2. | |
%% | |
%% Perimeter of a right-angled triangle | |
%% | |
%% - without knowing Hypotenuse | |
perimeter(A, B) -> | |
A + B + hypotenuse(A, B). | |
%% - with Hypotenuse | |
perimeter(A, B, H) -> | |
A + B + H. |
Thanks!
On the other hand, since that one is just a helper, you don't really need to export it.
Ah, ok! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is perfect! The use of the helper function
perimeter/3
is a nice touch. On the other hand, since that one is just a helper, you don't really need to export it.