Improving our functions with Bow

, Software Pundits
This post was originally published on this site

Apium Hub

**Bow is a library for Typed Functional Programming in Swift**

But first of all…

What is Functional Programming?

Functional Programming is a programming paradigm – a style of building the structure and elements of computer programs – that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. -Wikipedia

TL;DR: *Functional Programming is programming with functions.*

Functions must be:

-Total: There is an output for every input
– Deterministic: For a given input, the function always return the same output.
– Pure: The evaluation of the functions does not cause other effects besides computing the output.

But… All state is bad?

No, hidden, implicit state is bad.

Functional programming do not eliminate state, it just make it visible and explicit.

func add(x: Int, y: Int) -> Int { return x + y }

For example this functions is **total**, **deterministic** and **pure**. Always will return the

To read the full article click on the 'post' link at the top.