xmin <- -2 xmin <- -2 xmax <- 1 ymin <- -1 ymax <- 1 escapes <- function(cr, ci, it) { zr <- 0.0 zi <- 0.0 for (i in 1:it) { zrtmp <- zr*zr - zi*zi + cr zi <- 2*zr*zi + ci zr <- zrtmp if (zr*zr + zi*zi > 4) { return(TRUE) } } return(FALSE) } mandel <- function(xstep, ystep, iters) { for (yc in 0:(ystep-1)) { y <- yc*(ymax-ymin)/ystep + ymin for (xc in 0:(xstep-1)) { x <- xc*(xmax-xmin)/xstep + xmin if (escapes(x, y, iters)) { cat(' ') } else { cat('X') } } cat('\n') } } xstep <- strtoi(commandArgs(trailingOnly=TRUE)[1]) ystep <- strtoi(commandArgs(trailingOnly=TRUE)[2]) iters <- strtoi(commandArgs(trailingOnly=TRUE)[3]) mandel(xstep, ystep, iters)