Learning Track
The problems are numbered to match the original 99 Problems in Prolog. This is not the best order to tackle the problems if you are new, or new-ish to functional programming. This Learning Track presents an order designed to learn functional programming in a sequence that builds from the most basic idioms to more complex. The problems let you develop experience before moving on to the next concept. Each section presents a new technique and problems that you can solve with that technique.
- Simple List functions
- Passing functions as arguments
- Maybe Just Nothing
- Recursion
- Recursion on Lists
- Recursion on Binary Trees
- Map
- Fold
Note the Learning Track does not include all of the 99 problem, and sometimes repeats a problem so you can solve it a different way. For example you will solve Problem 4, countElements
, three different times, with three different approaches.
Problem presentation
Each section will have links to problems in order from simple to complex. This will often not be in numerical order. A link is provided to each problem page which has:
- The problem statement: Describes problem, and ask you to implement a solution.
- An example: Presents a example of the function with input and the correct result.
- A unit test: A complete program that executes multiple tests of problem solution. You can use this program on the Elm online editor, http:\/\/elm-lang.org\/try. The stubbed-out function you need to implement will be at the top, just below the imports.
- Hints: Suggests one or more ways to implement a solution.
- Solutions: Links to a page with one or more solutions.
Learning from the problems
Copy the unit test into the Elm online editor, http:/elm-lang.org/try, or in the debugger-enabled http://debug.elm-lang.org/try. Find the stubbed-out functions with comment -- your implementation goes here
. Attempt to implement the function. You may want or to write helper functions to complete your solutions.
Click "Compile" to test your code. If your solution is correct you will be rewarded with the message "Your implementation passed all tests". If tests fail, examine which tests failed and try again.
We learn best by doing, so before checking the hints or the solutions page, attempt to solve the problem yourself. Apply what you learned from the previous problems to solve the later problems. Then check the hints and see if that doesn't inspire other solutions or improvements to your own. Finally, check the solutions page to learn from those examples.
If you prefer to install Elm and compile your programs then include the module statement at the top of the test program.
module Main exposing (..)