Skip to Content
Learning Functional Programming in Go
book

Learning Functional Programming in Go

by Lex Sheehan
November 2017
Intermediate to advanced
670 pages
17h 35m
English
Packt Publishing
Content preview from Learning Functional Programming in Go

Function composition with linear and quadratic functions

Let's compose our f(x) = x2 + 1 quadratic equation with our g(x) = x + 2 linear equation table. Here's one way we could compose our two functions: y = f(g(x)). We'd say y equals f-compose-g of x or y = f o g where o is our composition operator. The way it works is that we assign a value for x, then we plug that value into g, compute g(x), and then plug the result into f.

We input 1 to g and to express that as g(1). We input g(1) to f to get f(g(1)).

Let's make it work by replacing g(1) with the value that maps from 1 to g(1), which is 3:

Replacing g(1) with 3, we get the following: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781787281394Supplemental Content