Skip to main content
3 of 3
added 7 characters in body
MD XF
  • 14.2k
  • 5
  • 70
  • 107

J, 73 bytes

load'viewmat' (0,?$~99 3)viewmat+/2<|(j./~i:2j479)(+*:) ::(3:)"0^:(i.99)0 

mandelbrot set

Edit, some explaining:

x (+*:) y NB. is x + (y^2) x (+*:) ::(3:) y NB. returns 3 when (+*:) fails (NaNs) j./~i:2j479 NB. a 480x480 table of complex numbers in required range v =: (j./~i:2j479)(+*:) ::(3:)"0 ] NB. (rewrite the above as one verb) v z0 NB. one iteration of the mandelbrot operation (z0 = 0) v v z0 NB. one iteration on top of the other (v^:n) z0 NB. the result of the mandelbrot operation, after n iterations i.99 NB. 0 1 2 3 4 ... 98 (v^:(i.99))0 NB. returns 99 tables, one for each number of iterations 2<| y NB. returns 1 if 2 < norm(y), 0 otherwise 2<| (v^:(i.99))0 NB. 99 tables of 1s and 0s +/... NB. add the tables together, element by element. NB. we now have one 480x480 table, representing how many times each element exceeded norm-2. colors viewmat M NB. draw table 'M' using 'colors'; 'colors' are rgb triplets for each level of 'M'. $~99 3 NB. 99 triplets of the numbers 99,3 ?$~99 3 NB. 99 random triplets in the range 0 - 98 and 0 - 2 0,?$~99 3 NB. prepend the triplet (0,0,0): black 
Eelvex
  • 5.6k
  • 1
  • 30
  • 46