Talk:Generator/Exponential

From Rosetta Code

"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)
I look forward to the new task and will try a change to this tasks wording later today as I would still like to hear from others trying it first if possible :-)
--Paddy3118 05:07, 23 November 2010 (UTC)