just read one of today's daily WTF's (http://thedailywtf.com/Articles/Stupid-Coding-Tricks-The-TSQL-Madlebrot.aspx)
(someone wrote a TSQL statement to "graph" the mandlebrot set)
and wanted to reproduce the TSQL code in oracle syntax.
I'm having troubles here - the idea is the following "with" clause produces all the cells (i) with their associated coordinates
but it doesn't appear to be working correctly. I havn't got 11g otherwise I'd just use the pivot command.
instead of manually attempting to pivot by referencing every field, I figured I just needed to concatenate every X value
but although it produces a pretty pattern I can't get it to produce the mandelbrot fractal
anyone with more experience want to give this a go? surely someone with a better understanding of the model clause could whip it up.
with t as (select ix, iy, substr(' .,,,-----++++%%%%@@@@### ',mod(max(i),26),1) I
from (
select ix, iy, x*x-y*y+(x-0.031) CX, y*x*2+(y-0.031) CY, x, y, rownum-1 i
from (select -2.2+ rownum*0.031 x, rownum ix
from dual
connect by rownum <= 100) xgen,
(select -1.5+rownum*0.031 y, rownum iy
from dual
connect by rownum <=100) ygen
where x-0.031*x-0.031 + y-0.031*y-0.031 < 16
connect by rownum <= 100)
group by ix, iy)
select replace(ltrim(max(sys_connect_by_path(i,'|')) keep (dense_rank last partition by ix),'|'),'|')
from (select ix, i, row_number() over (partition by ix order by iy) as rn
from t)
connect by ix = prior ix and rn = prior rn + 1
start with rn = 1
group by ix