From 91c9ee133605d4d8871b897b109a60f401b3aa79 Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Wed, 27 Apr 2016 18:13:24 +1200 Subject: [PATCH] Fixed >scaled in example. --- examples/mandelbrot.4th | 21 ++++++++++++++++++++- src/lib.4th | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) 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 -- 2.20.1