"The porcupine with the sharpest quills gets stuck on a tree more often."
Today's fortune"The porcupine with the sharpest quills gets stuck on a tree more often."
User loginNavigation |
Mandelbrot in scheme, now in Block Structure™
#!/usr/bin/env guile
!#
(define (mandelbrot left right bottom top)
(define cols 78)
(define rows 39)
(define iter 36)
(define (density n)
(cond ((= n iter) #\ )
((and (>= n 0) (<= n 9)) (integer->char (+ n 48)))
((and (>= n 10) (<= n 36)) (integer->char (+ n 35 -10)))
(else #\.)))
(define (mandelbrot left right bottom top)
(do ((i 0 (1+ i))) ((>= i rows))
(do ((j 0 (1+ j))) ((>= j cols))
(let ((x (+ (* (/ j cols) (- right left)) left))
(y (+ (* (/ i rows) (- top bottom)) bottom)))
(write-char (density (let lp ((c (make-rectangular x y))
(z 0+0i)
(k 0))
(cond ((or (= k iter) (>= (magnitude z) 2)) k)
(else (lp c (+ (* z z) c) (1+ k )) )) ))) ))
(newline)))
(mandelbrot left right bottom top))
(mandelbrot -2 2 -2 2)
Reply |
FriendsMainstream media |