Talk:Closures/Value capture: Difference between revisions

m
(→‎Proposed task tweak: Add the actual suggestion; d'oh!)
m (moved Talk:Closures/Variable capture to Talk:Closures/Value capture: Better describes the task)
 
(9 intermediate revisions by 4 users not shown)
Line 20:
==Proposed task tweak==
Wouldn't it be better if this task were to have functions/closures that didn't just return the value? Right now, the value returned is the same as the index into the list, which makes it harder to interpret the output. (Using the square of the value would be just as easy to implement, and yet be far clearer.) –[[User:Dkf|Donal Fellows]] 08:27, 21 July 2011 (UTC)
: I would be agreeable Unicon contributor --[[User:Dgamey|Dgamey]] 10:04, 21 July 2011 (UTC)
: Okay by me too. --[[User:TimToady|TimToady]] 20:48, 21 July 2011 (UTC)
:: I went ahead and changed it. Also changed the index requirement to 1-based, because to me that feels more language-neutral somehow. --[[User:Ledrug|Ledrug]] 01:19, 22 July 2011 (UTC)
:::If you want it language neutral, then don't mandate either 0 or 1 based indexing. It doesn't really matter much for demonstrating the feature. What does seem to matter a bit more is that the square be the square of the index, whichever is chosen, and we now have solutions where f[7] == 64, which bugs me somehow. --[[User:TimToady|TimToady]] 14:39, 22 July 2011 (UTC)
::::Fair enough. --[[User:Ledrug|Ledrug]] 14:52, 22 July 2011 (UTC)
What happens if the list is as follows?: a(), b(), a(),
::Should the first a() give 1, b() give 4, and the second a() give 9? [[User:Markhobley|Markhobley]] 13:42, 22 July 2011 (UTC)
 
Would this read better as "Create a list of up to 10 simple functions (anonymous functions are encouraged), so that the function returns the square of its position within the list."? [[User:Markhobley|Markhobley]] 13:52, 22 July 2011 (UTC)
Anonymous user