Not in python. It has no tail recursion so it will crash the
interpreter if you have more than ~1000 terms (depending on how python
was compiled).

On Feb 9, 6:16 am, cjrh <[email protected]> wrote:
> On Feb 8, 7:04 pm, António Ramos <[email protected]> wrote:
>
> > var1={'1':'','2':'','3':'','4':'','5':'','6':'','7':'','8':'','9':'','10':' 
> > ­','11':'','12':'','13':'','14':'','15':'','16':'','17':'','18':'','19':''}
>
> def f(i, d={}):
>     if i<=0:
>         return d
>     return f(i-1, dict(d.items() + [(str(i), '')]))
>
> print f(19)
>
> “To iterate is human, to recurse divine.”
> (L. Peter Deutsch)
>
> "I wouldn't actually do it this way in my own code"
> (Me)

Reply via email to