Fun with lambda and map

Gustavo Niemeyer niemeyer at conectiva.com
Tue Jan 29 06:44:31 EST 2002


> primes = lambda o:map(lambda a:filter(None,(map(lambda i:map(lambda
> x:a.__setitem__(x,0),range(2*i,o,i)),range(2,o)),a)[1])[1:],[range(o)])[0]
> 
> print primes(20)
> 
> fibonacci = lambda x:map(lambda o:(map(lambda c:map(lambda
> l:o.__setslice__(l[0],l[1],l[2]),([o[2]+3,o[2]+4,[o[0]]],[0,3,[o[1],reduce(lambda
> x,o:x+o,o[:2]),o[2]+1]])),range(x)),o)[1],[[1,1,0]+range(x)])[0][3:]
> 
> print fibonacci(20)

That proves you can write bad code in any language, if you really
want to...

;-)

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020129/7492f7a5/attachment.sig>


More information about the Python-list mailing list