sandbox/pe/geometry1.erl

16 lines
296 B
Erlang
Raw Permalink Normal View History

2019-04-22 14:01:00 +00:00
-module(geometry1).
-export([test/0, area/1]).
test() ->
12 = area({rectangle, 3, 4}),
144 = area({square, 12}),
tests_worked.
area({rectangle, Width, Height}) ->
Width * Height;
area({circle, Radius}) ->
3.14159 * Radius * Radius;
area({square, Side}) ->
Side * Side.