Recursive function returning a list
Bruno Desthuilliers
onurb at xiludom.gro
Thu Jul 20 08:27:01 EDT 2006
malkarouri at gmail.com wrote:
> Bruno Desthuilliers wrote:
>
>>malkarouri at gmail.com wrote:
>
> [...]
>
>>>Sorry, but I kinda agree with Boris here.
>>
>>On what ?
>
>
> On the argument that you are (implicitly?) disagreeing with him
it's getting messy - too much level of indirection !-)
> on,
> obviously. That the OP problem is not definitely the default values
> question.
Ok, I do agree that it's only *one* part of the problem - the other
(implied) being "what other possible solutions".
> As you say:
>
>
>>>>If the OP has other reasons to want to use an accumulator based solution
>>>>- which we don't know - then the possibility to use a default value is
>>>>important.
>
>
> My emphasis is on "we don't know".
At least we do agree on something !-)
>
>>>Not that I am anybody here,
>>>really.
>>
>>Err... Are you you at least ?-)
>>
>
>
> I am.
Great.
> Thanks for your concern:)
!-)
>
(snip)
>>>I don't think there is actually a FAQ
>>>saying you must use the accumulator solution.
>>
>>Did I say so ? The FAQ I mention is about default values evaluation, and
>>it's the problem the OP was facing. Please re-read my post more carefully.
>>
>
>
> Actually, I have read your post right first time. And I do know you
> didn't say that (a FAQ for accumulators). I raised it just in case.
> What I don't agree with is that it is not the problem the OP was
> facing. The discussion was: is the real problem the default values
> problem, which he already got a solution for. Or was the real problem
> the list returning recursion problem, for which he (or subsequent
> google searchers, who are more likely to come to this thread after
> searching for "Recursive function returning a list") may benefit from a
> generator approach.
agreed.
(snip)
> Thanks for the function, though I regard it as kind of trivial for the
> level of discussion that we are having now. The problem solved by the
> accumulator is _not_ the building of a list recursively. It is doing so
> efficiently. Which is definitely not done by creating multiple
> temporary lists just to add them. I am sure you know the theory. More
> of relevance is that the generator based solution has also the same
> efficiency, so they are both better than the trivial solution.
> You have a point though. Your function is a solution. Just I don't
> regard it as the preferred solution for the problem as I see it.
Nor do I.
>YMMV.
It doesn't
> To recap, the OP (and subsequent google searchers, if they pass by) has
> now the preferred solution according to you.
Please not that I didn't meant to present it as "the prefered solution".
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list