Unyeilding a permutation generator
Carsten Haese
carsten.haese at gmail.com
Sun Nov 2 17:03:25 EST 2008
sillyhat at yahoo.com wrote:
> Anyway what I want to do is experiment with code similar to this (i.e.
> same algorithm and keep the recursion) in other languages,
> particularly vbscript and wondered what it would look like if it was
> rewritten to NOT use the yield statement
An obvious (though memory-inefficient) replacement is to accumulate a
list and return the list. Initialize a result variable to an empty list,
and instead of yielding elements, append them to the result variable.
Then return the result variable at the end of the function.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
More information about the Python-list
mailing list