O'Reilly logo

Learning Elixir by Kenny Ballou

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Functional algorithms for everyday problems

Now that we have seen modules, functions, guards, the basic types of the previous chapter, and some basic examples of pattern matching, we essentially have everything we need to start solving problems. Let's take this further and actually write some code!

Let's solve some basic problems such as those you might find in your standard set of interview questions; however, instead of solving them with imperative code, we are going to see how we can solve them using only functional constructs and what we have covered so far.

Iteration versus recursion

Often in functional languages, we will use recursion instead of iteration since iteration, by its very nature, requires side-effects. That is, to use a for loop, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required