And here's another implimentation in some -very- ugly
Python. It is the result of trying to compose
Mandelbrot Set entirely of
List Comprehensions. Almost got there, but I couldn't manage to
shoehorn the core
iteration into a
list comprehension, so I was forced to use
reduce there.
As I said, this is ugly; it looks more like
scheme than python. There's some whitespace added, but (excluding the import) the whole
program is a single
statement.
This requires a python newer than 2.1, due to the use of
nested scopes. With 2.2 or newer, the import statement is unneeded.
thx to
jamesc for his shades
string.
#!/usr/bin/env python
from __future__ import nested_scopes
(lambda ITERS, BOUND, SCALE, RMIN, RMAX, IMIN, IMAX, STEP, SHADES,WRITE,LOG:
[r for r in range( RMIN*SCALE, RMAX*SCALE, STEP) if
WRITE('\n') or
[i for i in range(IMIN*SCALE, IMAX*SCALE, STEP) if
(lambda j : WRITE(SHADES[int(LOG(j+1))%len(SHADES)]))
((lambda k : reduce( lambda x, y : (abs(x[1]) <= BOUND) and
(x[0]+1, (x[1])**2 + y[1]) or
x,
[(0,k)]*ITERS))
(complex(r/SCALE, i/SCALE))[0])]])(
10000, 4, 150.0, -2.25, 1.5, -1.25, 1.25, 5, ".^:/I&@*%%$$###,",
__import__('sys').stdout.write, __import__('math').log)