Skip to content

Instantly share code, notes, and snippets.

@mareknowak
Last active May 6, 2020 18:32
Show Gist options
  • Save mareknowak/a1a6947af65b1dbea0643d9b7c55c6c1 to your computer and use it in GitHub Desktop.
Save mareknowak/a1a6947af65b1dbea0643d9b7c55c6c1 to your computer and use it in GitHub Desktop.
1.9
%% @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