Implementing collections via closures

If you've been working with functional or dynamic programming languages, you may feel that for loops and if statements produce verbose code. Using functional constructs such as map and filter for processing lists can be useful and make code appear more readable; however, in Go, these types are not in the standard library, and can be difficult to generalize without generics or very complex reflection and the use of empty interfaces. This recipe will provide you with some basic examples of implementing collections using Go closures.