Characteristics of FP

Let's start by looking at the requirements for a pure FP language. A pure FP language must include support for things like:

  • First-class functions
  • Tail-call optimization (TCO)
  • High-order functions
  • Pure functions
  • Immutable Data

In order to accomplish pure FP, a language must treat functions as it does any other variable type. How can an immutable language have variables that vary? The way we accomplish this in an FP way is by creating new variables, rather than modifying existing ones. We will see how to accomplish this later in the chapter, when we look at the Map function.

Go is a multidimensional language that supports imperative, object-oriented, and FP styles. We could write a purely imperative or functional program ...

Get Learning Functional Programming in Go 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.