: Works fine for me under 1.0.3. nice prime number generator..
: Was it susposed to crash or something?
Not at all...
It's just fun playing with lambda...
Two more examples: (assuming mail being faster than news, you'll know the
first one already)
==cut==
#!/usr/local/bin/python --
# "inline recursion" ;-)
# 1994-Aug-27, Ulf Bartelt
fib=lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f)
for i in range(10): print fib(i)
==cut==
...next...
==cut==
#!/usr/local/bin/python --
# 94-Aug-28, Ulf Bartelt
print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,\
Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,\
Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,\
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\
>=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(\
64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy\
))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)
# \___ ___/ \___ ___/ | | |__ lines on screen
# V V | |______ columns on screen
# | | |__________ maximum of "iterations"
# | |_________________ range on y axis
# |____________________________ range on x axis
# Hopefully someone will translate the following paragraph...
# Also...
# Spielen mit lambda, map, reduce und Co ist ja ganz nett, aber bei diesem
# Teil hier habe ich mir das Hirn schon arg verrenken muessen, damit es
# ueberhaupt laeuft...
# Zugegebenermassen ist es nahezu unmoeglich, bei solchen Exzessen den
# Ueberblick zu behalten und so habe ich sicherlich nicht die "eleganteste"
# Loesung gefunden...
==cut==
Bye !
Ulf.
-- Ulf Bartelt | 2:2437/120.666@fidonet.org | bartelt@sun2.isaf.tu-clausthal.de | | stub@linux.rz.tu-clausthal.de