Want to learn?

Modules and named functions exercises

Exercises

  1. Create Greeter module with hello_world function which prints "Hello world". Load it into IEx with different approaches to compile the file and check if it works.

  2. Extend Integer module with a zero? function which returns true if given integer is zero.

  3. Create circle_surface_area function inside of Math module, which calculates the surface area of a circle. Use @pi attribute.

  4. Create factorial function which calculates the factorial of the given number. It should use recursion and pattern matching to bind different arguments.

  5. Create fibonacci function which for given n number will print n-th fibonacci number.

  6. Create nested module School.Class.Teacher and give it an alias Professor.

  7. Create a contain_digits? function inside Checker module which takes a chars list as an argument and checks if it contains digits. Checking itself should be performed inside of a private function and result should be printed as a string message. Tip: check String.graphemes.

Start a project with your dedicated software house

Top

Contact us

* Required fields

Elo Mordo!Elo Mordo!