Functional programming

Functional programming is a programming paradigm where you model everything as a result of a function that avoids changing state and mutating data. We will discuss concepts such as state and data mutability and their importance in subsequent sections, but for reference, consider state as one of the different permutations and combinations that your program can have at any given time during its execution, whereas data mutability is the concept where a given dataset might change over a given course of time during program execution.

The same example that was given using imperative programming can be used in the following way using the functional approach:

let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]let numbersLessThanFive ...

Get Reactive Programming with Swift 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.