why 'lambda' and 'reduce'?

Anand Pillai pythonguy at Hotpop.com
Thu Jun 12 03:39:43 EDT 2003


This almost qualifies for an "obfuscated" code winner! ;-)

Anand Pillai

Manuel Garcia <news at manuelmgarcia.com> wrote in message news:<arnfevstdtqohla2l39717ch56saip8qce at 4ax.com>...
> If anyone ever asks for what good are 'lambda' and 'reduce', show them
> this...
> 
> print (lambda p:p[0]+'.'+p[1:])(
>     str((lambda(x,y,t,a):2L*x*x//a)(
>         (lambda F:(lambda S:reduce(
>             lambda(x,y,t,a),_:((x+y)//2L,
>                 S((x*y)//F),2L*t,
>                 (a-(t*(((x+y)//2L)**2-
>                        (S((x*y)//F))**2))//F)),
>             [0]*13,(F,(F*F)//S(2L*F),2L,F//2L)))(
>                 lambda n:reduce(lambda x,_:(
>                     x-x//2L+(n*F)//(2L*x)),
>                 [0]*15,
>                 n//2L)))(10L**(5010))))[:5000])
> 
> You have to be a bit patient with this one...
> 
> Manuel




More information about the Python-list mailing list