template re(creal x){const float re = x.re;} template im(creal x){const float im = x.im;} template sq(creal z){const creal sq = z*z;} template itoa(int i) { static if (i < 0) { static const char[] itoa = "-" ~ itoa!(-i); } else { static if (i / 10 > 0) { static const char[] itoa = itoa!(i / 10) ~ "0123456789"[i % 10]; } else { static const char[] itoa = "0123456789"[i % 10 .. i % 10 + 1]; } } } template sqrt(float x, int k = 5) { static if (k == 0) { const float sqrt = 1.f; } else { const float sqrt = .5f * (sqrt!(x, k-1) + x / sqrt!(x, k-1)); } } template iterations(creal c, int N) { static if(N == 1) { const creal iterations = c; } else { const creal iterations = sq!(iterations!(c,N-1)) + c; } } template escape(creal z) { const bool escape = (sqrt!(z.re*z.re + z.im*z.im) > 4); } template oneRow(creal c0, int count, int P) { static if(count == 0) { const char[] row = ""; } else { const c = iterations!(c0, 10); const char[] row = itoa!(escape!(c)) ~ oneRow!(c0 + cast(real)3/(P-1), count-1, P).row; } } template allRows(creal c0, int countRows, int countCols, int P) { static if(countRows != 0) { const c = c0; pragma(msg, oneRow!(c, countCols, countCols).row); alias allRows!(c0 + 1.0i*cast(real)2/(P-1), countRows-1, countCols, P) otherRows; } } alias allRows!(-2-1.0i, 33, 50, 33) go;