Get the latest tech news

Functional Programming in Go


Thanks to generics, there are some interesting new ways to program in Go. This article explains how we can use functional programming techniques like Map, Filter, and Reduce, and what kind of problems they might help us to solve.

Finally, we can reduce a slice to a single value by applying some function that combines elements (such as adding them up, for example). The technical term for this feature of a language is that its functions are first-class citizens: they’re on the same level as things like variables and literals, and can be used in the same way. In general, then, the function we pass to Reduce needs to take two things: a value representing the “current result” of the reduction (so far), and the next slice element to combine with it.

Get the Android app

Or read this on Hacker News