Anagram

Jonathan Hogg jonathan at onegoodidea.com
Wed Jan 23 14:05:47 EST 2002


On 23/1/2002 16:04 "Jason Orendorff" <jason at jorendorff.com> wrote:

> Actually the Lisp friend might like:
> 
> f = lambda s: reduce(lambda x,y:x*y+x, range(len(s)), 1)

I rather like:

    def Y( f ): return lambda x: f( Y(f), x )

    f = lambda s: Y( lambda f, x: x and x * f(x-1) or 1 )( len(s) )

Not the most concise, but it has a certain beauty to it :-)

Jonathan




More information about the Python-list mailing list