Manuel Albarran

defmoduleCircledodefstruct[:r]@doc"Calculates the area of a circle"defarea(%Circle{r:r}),do::math.pi*r*r@doc"Calculates the perimeter of a circle"defperimeter(%Circle{r:r}),do:2*:math.pi*renddefmoduleSquaredodefstruct[:a]@doc"Calculates the area of a square"defarea(%Square{a:a}),do:a*a@doc"Calculates the perimeter of a square"defperimeter(%Square{a:a}),do:4*aenddefmoduleRectangledodefstruct[:w,:h]@doc"Calculates the area of a polygon"defarea(%Rectangle{w:w,h:h}),do:w*h@doc"Calculates the perimeter of a polygon"defperimeter(%Rectangle{w:w,h:h}),do:2*w+2*henddefmodulePolygondodefcircularity(polygon)doarea=polygon|>polygon.__struct__.areaperimeter=polygon|>polygon.__struct__.perimeter(4*:math.pi*area)/(perimeter*perimeter)endend%Circle{r:10}|>Circle.area#> 304.0592653589793%Circle{r:10}|>Polygon.circularity#> 1.0 # A Perfect Circle%Square{a:10}|>Square.area#> 100%Square{a:10}|>Polygon.circularity#> 0.7853980633974483%Rectangle{w:10,h:5}|>Rectangle.area#> 50%Rectangle{w:10,h:5}|>Polygon.circularity#> 0.6981317007977318[%Circle{r:10},%Square{a:10},%Rectangle{w:10,h:5}]|>Enum.each(fnpolygon->IO.putspolygon|>polygon.__struct__.areaIO.putspolygon|>polygon.__struct__.perimeterIO.putspolygon|>Polygon.circularityend)#> 314.1592653589793#> 62.83185307179586#> 1.0#> 100#> 40#> 0.7853981633974483#> 50#> 30#> 0.6981317007977318