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

Referential transparency

Identifying when using monoid can help us make design decisions that affect performance.

On day one, we're asked to add 1 + 2 + 3. Then, on day two, we're asked to add 1 more. We don't have to add 1 + 2 + 3 again. We can simply store that and add our new 1 to it:  6 + 1 = 7.

Given that nothing is free, what did it cost us to gain the performance boost of not having to add 1 + 2 + 3? Storage. The question becomes, which is more costly? The answer to that will tell us whether to leverage referential transparency or not. Just because we can do something does not mean we always should.

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