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.

Check our latest product - it's based on our experience of managing over 50-people strong company. The tool we're missing as a small company and not an enterprise.

humadroid.io is an employee and performance management software. It's an unique tool allowing everyone to be in the loop - by having up to date info about co-workers, time-off, benefits, assets, helping with one-on-ones, being a go-to place for company-wide announcements.

Check out humadroid.io
Top

Contact us

* Required fields

The controller of your personal data provided via this contact form is Prograils sp. z o.o., with a registered seat at Sczanieckiej 9A/10, 60-215 PoznaƄ. Your personal data will be processed in order to respond to your inquiries and for our marketing purposes (e.g. when you ask us for our post-development, maintenance or ad hoc engagements for your app). You have the rights to: access your personal data, rectify or erase your personal data, restrict the processing of your personal data, data portability and to object to the processing of your personal data. Learn more.

Notice

We do not track you online. We use only session cookies and anonymous identifiers for the purposes specified in the cookie policy. No third-party trackers.

I understand
Elo Mordo!Elo Mordo!