Étude 3-4: Tuples as Parameters

Add an area/1 function that takes a tuple of the form {shape,number,number} as its parameter. Export it instead of area/3. The area/1 function will call the private area/3 function.

Here is some sample output.

1> c(geom).
{ok,geom}
2> geom:area({rectangle, 7, 3}).
21
3> geom:area({triangle, 7, 3}).
10.5
4> geom:area({ellipse, 7, 3}).
65.97344572538566

See a suggested solution in Appendix A.

Get Études for Erlang now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.