Skip to content

Instantly share code, notes, and snippets.

@pfiled
Created January 18, 2012 03:27
Show Gist options
  • Save pfiled/1630674 to your computer and use it in GitHub Desktop.
Save pfiled/1630674 to your computer and use it in GitHub Desktop.
week 1 erlang
-module(mathStuff).
-export([perimeter/1]).
perimeter({square,Side}) ->
4 * Side;
perimeter({circle,Radius}) ->
2 * 3.1415926 * Radius;
perimeter({triangle,A,B,C}) ->
A + B + C;
perimeter({polygon,L}) ->
lists:sum(L).
-module(temp).
-export([f2c/1, c2f/1, convert/1]).
f2c(F) ->
(F - 32) * 5 div 9.
c2f(C) ->
C * 9 div 5 + 32.
convert({c,T}) ->
c2f(T);
convert({f,T}) ->
f2c(T).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment