On Fri, Jan 17, 2014 at 2:24 PM, Petite Abeille <petite.abei...@gmail.com>wrote:
> > On Jan 17, 2014, at 7:47 PM, big stone <stonebi...@gmail.com> wrote: > > > - I just did my first recursive CTE under Ipython notebook. > > Finally! We can solve sudoku puzzles in SQL :P > Dan Kennedy, who created the common-table-expression that just found its way onto trunk, suggests the following query for computing the Mandelbrot Set as ascii-art: WITH RECURSIVE xaxis(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM xaxis WHERE x<110), yaxis(y) AS ( VALUES(1) UNION ALL SELECT y+1 FROM yaxis WHERE y< 30), m(iter, xpix, ypix, x, y) AS ( SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis UNION ALL SELECT iter+1, xpix, ypix, x*x-y*y + ((xpix * 3.5 / (SELECT count(*) FROM xaxis) - 2.5)), 2.0*x*y + ((ypix * 2.0 / (SELECT count(*) FROM yaxis) - 1.0)) FROM m WHERE (x*x + y*y) < 4.0 AND iter<50 ), m2(iter, xpix, ypix) AS ( SELECT max(iter), xpix, ypix FROM m GROUP BY xpix, ypix ), a(t) AS ( SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '' ) FROM m2 GROUP BY ypix ) SELECT substr(rtrim(t),15) FROM a; Copy/paste the above query into a file called "mandelbrot.txt" then run: ./sqlite3 <mandelbrot.txt -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users