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 - built from our experience helping growing businesses navigate complex compliance requirements without enterprise budgets.

humadroid.io is an affordable, all-in-one GRC platform designed for small and medium-sized businesses pursuing SOC 2 or ISO 27001 compliance. Our AI-powered compliance assistant understands your business context and transforms complex compliance work into actionable steps - generating tailored policy documentation in minutes instead of weeks, and helping draft your SOC 2 System Description in a fraction of the usual time. At just $250/month with no hidden fees or user limits, customers save 10-15 hours per week on compliance work.

Explore 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!