In order to accomplish everything we've spoken about so far, let's take a step back and explore some functions to traverse data, branching, and conditional dispatch, and other first order functions. The Clojure cheatsheet is a good location for a bird's-eye view of different categories of functions. Their official documentation can be found at http://clojure.org/cheatsheet.
Recursion in computer science is a technique where a function continuously calls itself until some decision point is reached (you can read more about this technique at https://en.wikipedia.org/wiki/Recursion_(computer_science)). This is useful when the same block of code needs to be run against successive or iterative contexts.
The reduce
function is used when we have a finite list that we need to collect or fold up into a result value.
Clojure also has the repeatedly
function, which continuously calls a function with no arguments. There's also iterate
, which is a single argument...