From: Tim Vaughan Date: Wed, 27 Apr 2016 06:13:24 +0000 (+1200) Subject: Fixed >scaled in example. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=91c9ee133605d4d8871b897b109a60f401b3aa79;p=forth.jl.git Fixed >scaled in example. --- diff --git a/examples/mandelbrot.4th b/examples/mandelbrot.4th index c75ebd0..55f746e 100644 --- a/examples/mandelbrot.4th +++ b/examples/mandelbrot.4th @@ -3,7 +3,15 @@ ( Location of floating point. ) : precision 10000 ; -: >scaled precision 10 / * swap precision * + ; +: sign dup abs / ; + +: >scaled + precision 10 / * over + ?dup 0<> if + sign * + then + swap precision * + +; ( Redefine multiplication. Yay forth! ) : * precision */ ; @@ -48,9 +56,20 @@ loop ; +: xsteps 100 ; +: ysteps 50 ; + ( Draw the Mandelbrot Set!) : mandel ( x1 y1 x2 y2 -- ) + 1 pick 4 pick - + 2 pick 5 pick do + i 0 inSet? if + 42 emit + else + '.' emit + then + dup +loop ; ( Clean up - hide non-standard multiplication def. ) diff --git a/src/lib.4th b/src/lib.4th index 7a3833d..ea4e7de 100644 --- a/src/lib.4th +++ b/src/lib.4th @@ -323,4 +323,4 @@ SWAP DROP ; - +include ../examples/mandelbrot.4th