Last active
May 6, 2020 18:32
-
-
Save mareknowak/a1a6947af65b1dbea0643d9b7c55c6c1 to your computer and use it in GitHub Desktop.
1.9
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
%% @doc Function for calculating area of any triangle and some auxiliary | |
%% functions | |
-module(first). | |
-export([area/3, double/1, mult/2, square/1, treble/1]). | |
mult(X, Y) -> | |
X * Y. | |
double(X) -> | |
mult(2, X). | |
square(X) -> | |
mult(X, X). | |
treble(X) -> | |
mult(3, X). | |
%% @doc Area of a triangle with sides A, B, and C | |
area(A, B, C) -> | |
S = (A + B + C) / 2, | |
math:sqrt(S * (S - A) * (S - B) * (S - C)). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment