Re:WTFPython – Understanding Python through surprising snippets
by gpderetta on Monday December 23, 2019 @10:38AM
(#21864252)
I know nothing about go, but it seems to me in your example powers_of_x is a list of n integers, while in the example being discussed is an list of n functions (which can be used to compute the n'th power).
Re:WTFPython – Understanding Python through surprising snippets
by masklinn on Monday December 23, 2019 @11:04AM
(#21864505)
I provided a Go example demonstrating that it does not. Your version
1. uses a slice of integers which completely misses the point
2. uses an IIFE which completely misses the point
The point is to look at what happens when you close over the iteration variable.
https://play.golang.org/p/pn2jBTaTNS8