Skip to content

Instantly share code, notes, and snippets.

@pppillai
Created May 6, 2020 18:54
Show Gist options
  • Save pppillai/37c6fa8f0a387a9d3c68f0a165b04a0b to your computer and use it in GitHub Desktop.
Save pppillai/37c6fa8f0a387a9d3c68f0a165b04a0b to your computer and use it in GitHub Desktop.
-module(second).
-import(first, [squareValue/1]).
-export([sizeOfHypotenuse/2, perimeterOfRightAngledTriangle/2, areaOfTriangle/2]).
%%below functions to be used for right angled triangle
%returns the hypotenuse
sizeOfHypotenuse(SideOne, SideTwo) ->
math:sqrt(squareValue(SideOne) + squareValue(SideTwo)).
%returns the perimeter
perimeterOfRightAngledTriangle(SideOne, SideTwo) ->
SideOne + SideTwo + sizeOfHypotenuse(SideOne, SideTwo).
%returns the area
areaOfTriangle(SideOne, SideTwo) ->
0.5 * SideOne * SideTwo.
@elbrujohalcon
Copy link

Nice one! Declarative names FTW!
Tip: In Erlang it's more idiomatic to use snake_case for function names, module names and atoms in general, instead of pascalCase.

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