Skip to content

Instantly share code, notes, and snippets.

@johnwalker
Created December 21, 2013 21:43
Show Gist options
  • Save johnwalker/8075503 to your computer and use it in GitHub Desktop.
Save johnwalker/8075503 to your computer and use it in GitHub Desktop.
-module(math1).
-export([area/1]).
area({square, Side}) ->
Side * Side;
area({rectangle, Side1, Side2}) ->
Side1 * Side2;
area({circle, Radius}) ->
3.1415926588375214 * Radius * Radius;
area({triangle, A, B, C}) ->
S = (A + B + C) / 2,
math:sqrt(S*(S-A)*(S-B)*(S-C)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment