Skip to content

Instantly share code, notes, and snippets.

@i7an
Created June 22, 2017 09:12
Show Gist options
  • Save i7an/6a869eb92016dc172461b1d5e68e852c to your computer and use it in GitHub Desktop.
Save i7an/6a869eb92016dc172461b1d5e68e852c to your computer and use it in GitHub Desktop.
My first Erlang program
-module(first).
-export([double/1,mult/2,area/3,square/1]).
mult(X,Y) ->
X*Y.
double(X) ->
mult(2,X).
square(A) ->
mult(A,A).
area(A,B,C) ->
S = (A+B+C)/2,
math:sqrt(S*(S-A)*(S-B)*(S-C)).
-module(second).
-import(first, [square/1, mult/2]).
-export([hypotenuse/2,perimeter/2,area/2]).
hypotenuse(A,B) ->
math:sqrt(square(A)+square(B)).
perimeter(A,B) ->
A+B+hypotenuse(A,B).
area(A,B) ->
mult(A,B)/2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment