-
Book Overview & Buying
-
Table Of Contents
Functional Programming in Go
By :
When talking about a purely functional programming language, we are talking about a language in which each function adheres to these properties:
This means that our functions are completely deterministic.
The best way forward might be to demonstrate what we are talking about by showing some examples. So, in this section, we’ll take a look at two functions, a pure one and another which is impure. Then, we’ll talk a bit more about the properties of such functions and their importance to the programs that we are writing.
A simple example of this would be an addition function. This is a function that takes two integers as input and returns the sum as the output:
func add(a, b int) int {
return a + b
}
When we call this function with the same inputs, we will get consistent output...