Talk:Closures/Value capture: Difference between revisions

It must be permissible to use different functions
(It must be permissible to use different functions)
Line 13:
:::Should the first a() give 1, b() give 2, and the second a() give 3? [[User:Markhobley|Markhobley]] 12:06, 20 July 2011 (UTC)
:::: It seems to create a list of 10 elements with each element being a call to the same function bound to the index position. Which is why it struck me that it is using a closure to simulate a constant. (Mind you shuffling the list elements could then be fun). --[[User:Dgamey|Dgamey]] 13:09, 20 July 2011 (UTC)
::::: It says a list of 10 functions. It must be permissible to use different functions, albeit, some of them may be listed more than once. If there was only one function repeated 10 times, it would not be much of a list (a bit like a shopping list for beer, beer, beer and beer): We might as well just pass the function just once, do away with the list, and just utilize the function ten times (or pass the function as the first argument and the number of utilizations as the second). [[User:Markhobley|Markhobley]] 17:16, 20 July 2011 (UTC)
 
:: Why 10 functions? Surely two or three would be sufficient to demonstrate how this works? The python example seems to put these in a list.
--[[User:Dgamey|Dgamey]] 11:46, 20 July 2011 (UTC)