Note
|
You can learn more about working with functions and modules in Chapters 2, 3, and 9 of Erlang Programming, Chapter 3 of Programming Erlang, Sections 2.3, 2.5, and 2.7 of Erlang and OTP in Action, and Chapters 2 and 3 of Learn You Some Erlang For Great Good!. There’s more on documentation in Chapter 18 of Erlang Programming and types in Chapter 30 of Learn You Some Erlang For Great Good!. |
Write a module with a function that takes the length and width of a rectangle and returns (yields) its area. Name the module geom, and name the function area. The function has arity 2, because it needs two pieces of information to make the calculation. In Erlang-speak: write function area/2.
Here is some sample output.
1> c(geom).
{ok,geom}
2> geom:area(3,4).
12
3> geom:area(12,7).
84
Document the geom module you wrote in Étude 2-1. See a suggested solution in Appendix A.
Document the area/2 function, and create an overview.edoc file to complete the documentation of the application you’ve written. See a suggested solution in Appendix A.