beginner <zyzhu2000@gmail.com> writes:
> 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.
This is very 'functional' (and also quite concise):
f = compose(list,partial(unfold, divmod(_,26)))
The definitions of compose, unfold, and _ are left as excercises (of
increasing difficulty) for the reader.
'as