Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements flatmap and iteration methods for Some and Nothing
flatmap is the composition of map and flatten. It is important for functional programming patterns. Some tasks that can be easily attained with list-comprehensions, including the composition of filter and mapping, or flattening a list of computed lists, can only be attained with do-syntax style if a flatmap functor is available. (Or appending a `|> flatten`, etc.) Filtering can be implemented by outputing empty lists or singleton lists for the values to be removed or kept. A more proper approach would be the optional monad, though, usually implemented in Julia as a union of Some and Nothing. This patch therefore also implements iteration methods for Some and Nothing, to enable the filtermap pattern with flatmap.
- Loading branch information