Created
December 20, 2009 02:54
-
-
Save kosh04/260340 to your computer and use it in GitHub Desktop.
Mandelbrot Set ASCII art for newLISP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env newlisp | |
;;; Mandelbrot Set ASCII art (tested newLISP v.10.3.0) | |
;;; Original: (Common Lisp) | |
;; - http://groups.google.com/group/comp.lang.lisp/msg/d786bbde308e8175 | |
;; - http://bc.tech.coop/blog/040811.html | |
;;; Usage: | |
;; $ ./mandelbrot.lsp | |
;; | |
;; ~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}||||||||{{{zyvrwuR{|||||}}}}}}~~~~~~~~~~~~~ | |
;; ~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{zyxwoaqwxz{{{|||||}}}}}}~~~~~~~~~~ | |
;; ~~~~~~~~}}}}}}}}}}}}}}}}}}}|||||||||{{zzzyxvn Knwyz{{{{||||}}}}}}~~~~~~~~ | |
;; ~~~~~~}}}}}}}}}}}}}}}}}}||||||||{{zyxuxxxwvuq svwwyzzzyr{||}}}}}}}~~~~~~ | |
;; ~~~~}}}}}}}}}}}}}}}}}|||||{{{{{zzzxt> qf pttfqeqz{|}}}}}}}}~~~~ | |
;; ~~~}}}}}}}}}}}}}}|||{{{{{{{{{zzzywotn atyz{||}}}}}}}}~~~ | |
;; ~~}}}}}}}}}||||{{zwvyyyyyyyyyyyxvsP swvz{||}}}}}}}}~~ | |
;; ~}}}}|||||||{{{{zyxvpN[ur]spvwwvi qxz{|||}}}}}}}}~ | |
;; ~}||||||||{{{{{zyytun qq avz{|||}}}}}}}}~ | |
;; ~||||||{zzzzyyxtroqb a xz{{|||}}}}}}}}~ | |
;; ~>E9. 4" % pvxyz{{||||}}}}}}}~ | |
;; ~||||||{zzzzyyxtroqb a xz{{|||}}}}}}}}~ | |
;; ~}||||||||{{{{{zyytun qq avz{|||}}}}}}}}~ | |
;; ~}}}}|||||||{{{{zyxvpN[ur]spvwwvi qxz{|||}}}}}}}}~ | |
;; ~~}}}}}}}}}||||{{zwvyyyyyyyyyyyxvsP swvz{||}}}}}}}}~~ | |
;; ~~~}}}}}}}}}}}}}}|||{{{{{{{{{zzzywotn atyz{||}}}}}}}}~~~ | |
;; ~~~~}}}}}}}}}}}}}}}}}|||||{{{{{zzzxt> qf pttfqeqz{|}}}}}}}}~~~~ | |
;; ~~~~~~}}}}}}}}}}}}}}}}}}||||||||{{zyxuxxxwvuq svwwyzzzyr{||}}}}}}}~~~~~~ | |
;; ~~~~~~~~}}}}}}}}}}}}}}}}}}}|||||||||{{zzzyxvn Knwyz{{{{||||}}}}}}~~~~~~~~ | |
;; ~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{zyxwoaqwxz{{{|||||}}}}}}~~~~~~~~~~ | |
;; ~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}||||||||{{{zyvrwuR{|||||}}}}}}~~~~~~~~~~~~~ | |
;; ~~~~~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}}|||||{zmt{{{||||}}}}}~~~~~~~~~~~~~~~~~ | |
;; this is FOOP (Functional Object Oriented Programming) application. | |
;; http://www.newlisp.org/complex.txt | |
(new Class 'Complex) | |
(define (Complex:rad ) | |
(sqrt (add (pow (self 1)) (pow (self 2))))) | |
(define (Complex:add b) | |
(Complex (add (self 1) (b 1)) (add (self 2) (b 2))) ) | |
(define (Complex:mul b) | |
(let ((a.re (self 1)) (a.im (self 2)) | |
(b.re (b 1)) (b.im (b 2))) | |
(Complex (sub (mul a.re b.re) (mul a.im b.im)) | |
(add (mul a.re b.im) (mul a.im b.re))))) | |
(context MAIN) | |
(for (y -1 1.1 0.1) | |
(for (x -2 1 0.04) | |
(letn ((c 126) | |
(z (Complex x y)) | |
(a z)) | |
(while (and (begin | |
(setq z (:add (:mul z z) a)) | |
(< (abs (:rad z)) 2)) | |
(< 32 (dec c)))) | |
(print (char c)))) | |
(println)) | |
(exit) | |
;;; EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FIXME: FOOPの仕様変更のおかげで現行のnewLISP(v10.2.8)ではComplex周りが動かない