What is the "functional" way of doing this?

beginner zyzhu2000 at gmail.com
Tue Jul 31 17:56:09 CEST 2007


On Jul 30, 5:48 pm, beginner <zyzhu2... at gmail.com> wrote:
> Hi,
>
> If I have a number n and want to generate a list based on like the
> following:
>
> def f(n):
>      l=[]
>      while n>0:
>          l.append(n%26)
>          n /=26
>     return l
>
> I am wondering what is the 'functional' way to do the same.
>
> Thanks,
> beginner

I see. It is interesting (and not surprisingly) that recursion or
yield are required. Thanks for everyone's help.




More information about the Python-list mailing list