Talk:Generator/Exponential: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎"Draft" reasoning: synthesize a signature...)
(→‎"Draft" reasoning: Feel free to help edit the task (I've got a watch on the page; I'll notice…))
Line 13: Line 13:
:Note that this tasks ''requires'' the use of generators in the calculation of the result.
:Note that this tasks ''requires'' the use of generators in the calculation of the result.
::<small>(Preceding comment by [[User:Paddy3118|Paddy3118]])</small>
::<small>(Preceding comment by [[User:Paddy3118|Paddy3118]])</small>

: Feel free to edit the task. Note that I was trying hard to make it so that it didn't require Stackless Python; that's a bit of an artificial restriction for someone coming from the Tcl world, where we didn't even bother trying to do coroutines until we had a stackless execution engine. Mind you, being able to put the yield deep inside is in general much more useful; the code between the outermost level and the point where it yields can be actually written to be unaware that it is in a generating context, which leads to cool tricks with coöperative multitasking. Maybe I'll work those into another task sometime. –[[User:Dkf|Donal Fellows]] 00:21, 23 November 2010 (UTC)

Revision as of 00:21, 23 November 2010

"Draft" reasoning

Draft is mainly because I'm not sure if I have the task right, or that I've done a particularly good job of describing a generator either. IOW, review needed. –Donal Fellows 14:03, 22 November 2010 (UTC)

Hi Donal, I tried to first understand your task description but got nowhere, so converted your Tcl to Python without understanding what it did, then printed the squares, then your filtered sequence to find that it is a list of the squares of positive integers with any that are also cubes of integers taken out. After working that out, your textual description then made perfect sense :-)
That is how it goes for me; sometimes I need the numbers to understand the text. I would wait to see what others think before acting on my tale, but I would suggest the task be formalised as maybe:

1. Create a function returning a generator of the m'th powers of the positive integers starting from zero
2. Use it to create a generator of:
2.1. Squares.
2.2. Cubes.
3. Create a new generator that filters all cubes from the generator of squares.
4. Drop the first 20 values from this last generator of filtered results then show the next 10 values
Note that this tasks requires the use of generators in the calculation of the result.
(Preceding comment by Paddy3118)
Feel free to edit the task. Note that I was trying hard to make it so that it didn't require Stackless Python; that's a bit of an artificial restriction for someone coming from the Tcl world, where we didn't even bother trying to do coroutines until we had a stackless execution engine. Mind you, being able to put the yield deep inside is in general much more useful; the code between the outermost level and the point where it yields can be actually written to be unaware that it is in a generating context, which leads to cool tricks with coöperative multitasking. Maybe I'll work those into another task sometime. –Donal Fellows 00:21, 23 November 2010 (UTC)