Discovering the NSIterate namespace and its helper functions
Except for a number of methods available in Bosque core collections, there is one more way in which to do iteration in Bosque. We can make use of the NSIterate
namespace and its functions. While I'm writing this, there are four functions in this namespace that we will discuss here:
while<S>()
until<S>()
steps<S>()
reduce<T>()
We will now cover these briefly one by one. Let's start with the last one mentioned – the reduce<T>()
function.
The reduce<T>() function
In functional programming, reducing is an operation that processes a data collection in order to produce a result using some kind of a function that combines the collection elements. So, in other words, reducing means transforming the whole collection of data into one end result. The reduce<T>()
function in Bosque is used exactly for that. It's parametrized by a type, T...