let xmin:float = -2 let xmax:float = 1 let ymin:float = -1 let ymax:float = 1 proc escapes(cr: float, ci: float, it: int): bool {. noSideEffect .} = var zr: float = 0.0 var zi: float = 0.0 var tmp: float for i in countup(1, it): # z <- z^2 + c tmp = zr*zr - zi*zi + cr zi = 2*zr*zi + ci zr = tmp if unlikely(zr*zr + zi*zi > 4): result = true return result = false proc main(xstep: int, ystep: int, iters: int) = #var xc, yc: int var x, y: float for yc in countup(0, ystep-1): y = toFloat(yc)*(ymax-ymin)/toFloat(ystep) + ymin for xc in countup(0, xstep-1): x = toFloat(xc)*(xmax-xmin)/toFloat(xstep) + xmin if escapes(x, y, iters): write(stdout, ' ') else: write(stdout, 'X') write(stdout, "\n") import os import strutils main(parseInt(paramStr(1)), parseInt(paramStr(2)), parseInt(paramStr(3)))