1 # Auch das ist KEIN typischer Python-Code, lediglich der Beweis dafuer,
2 # dass man auch in Python abgefahrene Einzeiler basteln kann.
3
4 # Aus der Python-FAQ:
5
6 # 4.15. Is it possible to write obfuscated one-liners in Python?
7 # Yes. See the following three examples, due to Ulf Bartelt:
8
9 # Primes < 1000
10 print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0,
11 map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000)))
12
13 # First 10 Fibonacci numbers
14 print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f),
15 range(10))
16
17 # Mandelbrot set
18 print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,
19 Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
20 Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
21 i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y
22 >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(
23 64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy
24 ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)
25 # \___ ___/ \___ ___/ | | |__ lines on screen
26 # V V | |______ columns on screen
27 # | | |__________ maximum of "iterations"
28 # | |_________________ range on y axis
29 # |____________________________ range on x axis
30
31 # Don't try this at home, kids!