Skip to content

Instantly share code, notes, and snippets.

@kosh04
Created December 20, 2009 02:54
Show Gist options
  • Save kosh04/260340 to your computer and use it in GitHub Desktop.
Save kosh04/260340 to your computer and use it in GitHub Desktop.
Mandelbrot Set ASCII art for newLISP
#!/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
@kosh04
Copy link
Author

kosh04 commented Jul 5, 2010

FIXME: FOOPの仕様変更のおかげで現行のnewLISP(v10.2.8)ではComplex周りが動かない

直した (2011-02-03)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment