SQL
AخA
WITH RECURSIVE xaxis(x) AS (
VALUES(cast(-2.0 as double))
UNION ALL SELECT x + 0.05 FROM xaxis WHERE x < 1.2
),
yaxis(y) AS (
VALUES(cast(-1.0 as double))
UNION ALL SELECT y + 0.1 FROM yaxis WHERE y < 1.0
),
m(iter, cx, cy, x, y) AS (
SELECT 0, x, y, cast(0.0 as double), cast(0.0 as double)
FROM xaxis, yaxis
UNION ALL
SELECT iter + 1, cx, cy, x * x - y * y + cx, 2.0 * x * y + cy
FROM m
WHERE (x * x + y * y) < 4.0 AND iter < 38
),
m2(iter, cx, cy) AS (
SELECT max(iter), cx, cy FROM m GROUP BY cx, cy
),
a(t) AS (
SELECT
group_concat(
substr(' ░▒▓█', 1 + least(floor(iter / 7.0), 4), 1)
ORDER BY cx SEPARATOR ''
)
FROM m2 GROUP BY cy
)
SELECT replace(t, ' ', x'e29681e280af') 'Mandelbrot' FROM a;
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.