The Lambda Lab
/
projects
/
forth.jl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed */ def, added fixed point arithmetic to example.
[forth.jl.git]
/
examples
/
mandelbrot.4th
diff --git
a/examples/mandelbrot.4th
b/examples/mandelbrot.4th
index
254628c
..
c75ebd0
100644
(file)
--- a/
examples/mandelbrot.4th
+++ b/
examples/mandelbrot.4th
@@
-1,4
+1,12
@@
-( --- Complex integer arithmetic --- )
+( --- Complex arithmetic --- )
+
+( Location of floating point. )
+: precision 10000 ;
+
+: >scaled precision 10 / * swap precision * + ;
+
+( Redefine multiplication. Yay forth! )
+: * precision */ ;
: c* ( x1 y1 x2 y2 -- x3 y3 )
swap -rot ( x1 x2 y1 y2 )
: c* ( x1 y1 x2 y2 -- x3 y3 )
swap -rot ( x1 x2 y1 y2 )
@@
-28,15
+36,22
@@
: inSet? ( cr ci -- res )
: inSet? ( cr ci -- res )
- 100 0
DO
+ 100 0
do
- 2
SWAP 2DUP 5 ROLL 5 ROLL
+ 2
swap 2dup 5 roll 5 roll
iterate
iterate
- 2DUP cmagsq
- 100 > IF
- LEAVE
- THEN
+ 2dup cmagsq
+ 100 > if
+ leave
+ then
+
+ loop
+;
+
+( Draw the Mandelbrot Set!)
+: mandel ( x1 y1 x2 y2 -- )
- LOOP
;
;
+( Clean up - hide non-standard multiplication def. )
+hide *