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

Building functional projects

We have a lot in our proverbial tool belt so far and we are adding more. Let's take a look at some more examples where we solve some relatively simple problems using Elixir. This time, however, let's use mix as well.

Flatten

We will start small, by creating a function to flatten arbitrarily deep, nested lists.

Let's create a project for it using mix new flatten:

$ mix new reverse
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/flatten.ex
* creating test
* creating test/test_helper.exs
* creating test/flatten_test.exs

Your mix project was created successfully.
You can use mix to compile it, test it, and more:

    cd flatten
 mix test ...

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