Home

On Jul 30, 4:39 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> "attn.steven....@gmail.com" <attn.steven....@gmail.com> writes:
> > Recursion is common in functional programming:
>
> > def f(n, l=None):
> > if l == None:
> > l = []
> > if n > 0:
> > return f(n/26, l + [n%26])
> > else:
> > return l
>
> > print f(1000)
>
> Right, this is functional style, but quite painful in Python (no tail
> recursion, and look at all that list copying).



Yes, I agree that performance would greatly suffer. This
is really idomatic Lisp re-written as Python and was the first
thing that popped into my head when the OP mentioned 'functonal'.

Your generator/iterator solution should run must faster.

--
Regards,
Steven

previous
next

Re: 2 daemons write to a single file /w python file IO
How to call module functions inside class instance functions?
Pattern for error checking easiest-first?
Re: sorteddict PEP proposal [started off as orderedict]
Re: Misleading wikipedia article on Python 3?
Fundacja Avalon
Kidprotect
Fundacja Iskierka
Mam Marzenie
Fundacja Sloneczko