Course of Raku / Advanced / Modules / Modules basics / Exercises / A maths module
Solution: A maths module
Here is a possible solution to the task. It uses two files.
Code
The module, Maths.rakumod:
unit module Maths;
sub square($n) is export {
$n * $n
}The program, maths.raku:
use Maths;
say square(6);🦋 You can find both source files in the exercises/advanced/modules-basics/maths-module directory.
Output
$ raku -I. maths.raku
36Comments
The module marks
squarewithis export, which is what makes it available to the program that uses it.The
-I.option puts the current directory on the module search path, so Raku findsMaths.rakumodnext to the program.
Course navigation
← A maths module | A shout module →