Learning Functional Programming in Go
上QQ阅读APP看书,第一时间看更新

Pure function

A pure function is a function that when given the same input will always return the same output and will not have any observable side effects. How is that a benefit? Let's see. We can run any pure function in parallel since our functions do not need access to shared memory. Race condition due to side effects are not possible with pure functions. The performance gains of running our code concurrently on multiple cores is another awesome benefit of FP.