Created
February 28, 2017 22:51
-
-
Save conradwt/543c998970c6190b01113c6c31f1d0a7 to your computer and use it in GitHub Desktop.
Functional Programming Erlang - 1.9 - My first Erlang program
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
-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