Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - wandernet

#1
newLISP in the real world / Re: SBCL to newLISP
June 29, 2010, 02:40:20 AM

;newLISP v.10.0.0
;on Win32 IPv4 UTF-8
(import "kernel32.dll" "GetTickCount")
(set 'BAILOUT 16)
(set 'MAX_ITERATIONS 1000)

(define (iterate x y)
  (let ((cr (sub y 0.5))
   (ci x)
   (zi 0.0)
   (zr 0.0)
   (i 0))
(while 1
 (inc i 1)
 (set 'temp (mul zr zi))
 (set 'zr2 (mul zr zr))
 (set 'zi2 (mul zi zi))
 (set 'zr  (add cr (sub zr2 zi2)))
 (set 'zi  (add temp temp ci))
 (if (> (add zi2 zr2) BAILOUT)
        (throw i))
 (if (> i MAX_ITERATIONS)
   (throw 0)))))

(define (mandelbrot)
    (let ((t (GetTickCount)))
 (for (y -39 38)
(for (x -39 38)
(set 'j (catch (iterate (div x 40.0) (div y 40.0))))
            (if (= j 0.0)
 (print "*")
 (print " ")))
(print "n"))
 (println "Time Elapsed: " (- (GetTickCount) t))))

(mandelbrot)