Skip to content

Instantly share code, notes, and snippets.

@slapers
Last active May 5, 2020 09:33
Show Gist options
  • Save slapers/78425e712cd9624140da91819bd2d6c3 to your computer and use it in GitHub Desktop.
Save slapers/78425e712cd9624140da91819bd2d6c3 to your computer and use it in GitHub Desktop.
erlang-mooc-exercise-1.9
-module(first).
-export([double/1, mult/2, area/3, square/1, treble/1]).
mult(X, Y) ->
X * Y.
double(X) ->
mult(2, X).
treble(X) ->
mult(3, X).
area(A, B, C) ->
S = (A + B + C) / 2,
math:sqrt(S * (S - A) * (S - B) * (S - C)).
square(X) ->
mult(X, X).
-module(second).
-export([hypotenuse/2, perimeter/2, area/2]).
hypotenuse(A, B) ->
ABS = first:square(A) + first:square(B),
math:sqrt(ABS).
perimeter(A, B) ->
A + B + hypotenuse(A, B).
area(A, B) ->
A * B / 2.
@elbrujohalcon
Copy link

Great job!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment