Skip to content

Instantly share code, notes, and snippets.

@garrensmith
Created January 11, 2012 15:49
Show Gist options
  • Select an option

  • Save garrensmith/1595268 to your computer and use it in GitHub Desktop.

Select an option

Save garrensmith/1595268 to your computer and use it in GitHub Desktop.
Couchdb and erlang course
-module(mathStuff).
-export([perimeter/1]).
perimeter({square,Side}) ->
Side * 4;
perimeter({rectangle,A,B}) ->
(A * 2) + (B * 2);
perimeter({circle,Radius}) ->
Radius * 2 * 3.1415;
perimeter({triangle,A,B,C}) ->
A + B + C.
-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,C}) ->
{f,c2f(C)};
convert({f,F}) ->
{c,f2c(F)};
convert({_,_}) ->
io:format("Incorrectly formatted ~n").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment