Skip to content

Instantly share code, notes, and snippets.

@mareknowak
Last active May 6, 2020 18:29
Show Gist options
  • Select an option

  • Save mareknowak/ae28009492308cac5f1d605ac525c798 to your computer and use it in GitHub Desktop.

Select an option

Save mareknowak/ae28009492308cac5f1d605ac525c798 to your computer and use it in GitHub Desktop.
1.9
%% @doc Functions for calculating perimeter and area of a right angled triangle
-module(second).
-export([hypotenuse/2, perimeter/2, area/2]).
hypotenuse(A, B) ->
math:sqrt(first:square(A) + first:square(B)).
%% @doc Perimeter of a right angled triangle
%% A, B - lengths of shorter sides
%% C - hypotenuse
perimeter(A, B) ->
C = hypotenuse(A, B),
(A + B + C).
%% @doc Area of a right angled triangle
%% A, B - lengths of shorter sides
%% instead of (0.5 * A * B) we have more
%% fancy area calculation
area(A, B) ->
C = hypotenuse(A, B),
first:area(A, B, C).
@elbrujohalcon
Copy link

Nice docs!!! You can add an @doc tag to them to allow edoc to generate project documentation eventually.

@mareknowak
Copy link
Author

Done. Thanks!

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