Skip to content

Instantly share code, notes, and snippets.

@conradwt
Created February 28, 2017 22:51
Show Gist options
  • Save conradwt/543c998970c6190b01113c6c31f1d0a7 to your computer and use it in GitHub Desktop.
Save conradwt/543c998970c6190b01113c6c31f1d0a7 to your computer and use it in GitHub Desktop.
Functional Programming Erlang - 1.9 - My first Erlang program
-module(second).
-export([hypotenuse/2,perimeter_right_triangle/2,area_right_triangle/2]).
% Using the function square from first.erl, define a function that gives the
% size of the hypotenuse of a right-angled triangle given the lengths of the
% two other sides.
hypotenuse(A,B) ->
math:sqrt(A*A + B*B).
% Define functions that give the perimeter and area of a right-angled triangle,
% given the lengths of the two short sides.
perimeter_right_triangle(A,B) ->
(A + B)/2.
area_right_triangle(A,B) ->
(A*A + B*B)/2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment