I remember the class of professor Ismar Frango, back in 2012 on Paradigms of programming. It was mind blowing to think recursively but to implement in C or C++ it was a bit tough. Nowadays, with python and elixir, dude! it’s much easier.


I started learning Elixir some time back, when I make a mistake in one of my python programs and Elixir came with “end” in function. It was like, well, this is a broken python. But not, it’s much more than that.

To learn I use this blog [2] and this tutorial [1] It’s from there that I stole the code below. Elixir is very powerful for pattern matching [3].

defmodule Recursion do
  def print_multiple_times(msg, n) when n <= 1 do
    IO.puts msg

  def print_multiple_times(msg, n) do
    IO.puts msg
    print_multiple_times(msg, n - 1)

Recursion.print_multiple_times("Hello!", 3)



[1] https://www.youtube.com/watch?v=pBNOavRoNL0

[2] https://elixir-lang.org/getting-started/recursion.html



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s