Fun with functions
The goal of the exercises on this Lab session is to get acquainted with the paradigm of functional programming. Therefore, you are asked to solve the exercices using only pattern matching and recursion. More specifically, this means that you should avoid using Elixir’s standard libraries (e.g. Enum, List, Map).
By the same token, we would like to introduce the test-driven approach to software development (TDD). In a nutshell, this means that we would start with one test case at a time and use it to uncover the solution to the problem at hand, incrementally. That that end, at the beginning of each exercise, you will be asked to retrieve a zip file containing the skeleton of an Elixir application and a set of test cases that you should enable one by one. The order of the tests has been selected in a way that they will help you in the process of deriving your solution. Each test case has a tag
@tag :pending which precedes the body of the test. Removing (or commenting out) the tag line will enable the corresponding test case.
#To enable one test case, open the file
test/exercise1_test.exs and remove (or comment out) the line
@tag :pending which precedes the code of the test case. For instance, to enable first test case you have to comment line number 4 on
test/exercise1_test.exs, which should look like the first line in the snippet below:
To run the test cases, on a terminal window, enter the following command:
Analyze carefully the information dumped by the command above, as it is usually there where you would find hints on how to proceed. Once you get one test case passing, keep it. Do not tag it as
pending again! This would ensure that you preserve the already uncovered requirements as you progress in your implementation.
Let us start our journey, good luck!