Skip to content

Instantly share code, notes, and snippets.

@hhimanshu
Created December 16, 2014 21:54
Show Gist options
  • Save hhimanshu/dff16665a12e424e4b22 to your computer and use it in GitHub Desktop.
Save hhimanshu/dff16665a12e424e4b22 to your computer and use it in GitHub Desktop.
Erlang: Find Perimeter
-module(mathStuff).
-export([perimeter/1]).
perimeter({circle, Radius}) -> 2 * math:pi() * Radius;
perimeter({square, Side}) -> 4 * Side;
perimeter({triangle, A, B, C}) -> A + B + C.
@Kintull
Copy link

Kintull commented Oct 6, 2016

Add check for invalid values of radius and sides
Also check if triangle exist

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