On Sat, Nov 5, 2011 at 1:50 PM, mikel paternain <[email protected]> wrote: > In the amazing book Chaos and Fractals New frontiers of Science, the authors > described a simple algorithm for making the Sierpinski Gasket. This is > perhaps the most short and efficient algorithm (in non tacit programming > languages) for computing this fractal. > The basic algorithm is(in pseudocode): > > Define x,y > For y=0 to 255 > For x=0 to 255 > If /x And y)=0 Then Pset(x,y) //Pset is a function for drawing the > point x,y > Next x > Next y > End > > With my little experience inJ the question is how translate this code to J . > Help me please!
require'viewmat' viewmat *17 b./~i.255 In other words 17 b. is "and" i.255 is x (and is also y) 17 b./ treats x and y independently (i.255) 17 b./ i.255 can be simplified to 17 b./~ i.255 and, * is 1 for any positive value and 0 for any negative value -- and since you are using viewmat it does not matter whether you are using 1 and 0 or 0 and 1. A more literal translation would be: viewmat 0 = 17 b./~i.255 but it's still the same fractal, either way. FYI, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
