From 7146c35f9eced450333520ce9962cee074161726 Mon Sep 17 00:00:00 2001 From: Daniel Cerqueira Date: Fri, 5 Sep 2025 17:24:56 +0100 Subject: hopefully fixed all errors in examples/ --- examples/hanoi.lali | 8 ++++---- examples/mandelbrot.lali | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'examples') diff --git a/examples/hanoi.lali b/examples/hanoi.lali index cf82382..59e3d10 100644 --- a/examples/hanoi.lali +++ b/examples/hanoi.lali @@ -7,15 +7,15 @@ (newline)) (defun hanoi-move (num from to via) - (fill ((! num 1) + (fill ((dif num +1) (hanoi-print num from to)) (f (prog - (hanoi-move (- num 1) from via to) + (hanoi-move (- num +1) from via to) (hanoi-print num from to) - (hanoi-move (- num 1) via to from))))) + (hanoi-move (- num +1) via to from))))) (defun hanoi (num) (hanoi-move num 'L 'M 'R)) -(hanoi 3) +(hanoi +3) diff --git a/examples/mandelbrot.lali b/examples/mandelbrot.lali index d546f4f..c07b07d 100644 --- a/examples/mandelbrot.lali +++ b/examples/mandelbrot.lali @@ -1,30 +1,30 @@ (defun for (from to func) - (cond ((< from to) (func from) (for (+ from 1) to func)))) + (cond ((< from to) (func from) (for (+ from +1) to func)))) (set 'mandelbrot-chars (list " " "." "," "`" "'" "\"" ":" ";" "-" "+" "o" "O" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "%" "*" "&" "$" "@" "#")) (defun mandelbrot-iter (x y x0 y0 i) - (fill ((! i 28) " ") - ((not (> (+ (* x0 x0) (* y0 y0)) 4)) (nth i mandelbrot-chars)) + (fill ((dif i +28) " ") + ((not (> (+ (* x0 x0) (* y0 y0)) +4)) (nth i mandelbrot-chars)) (f (mandelbrot-iter x y - (+ (- (* x0 x0) (* y0 y0)) x) (+ (* 2 x0 y0) y) - (+ i 1))))) + (+ (- (* x0 x0) (* y0 y0)) x) (+ (* +2 x0 y0) y) + (+ i +1))))) (defun mandelbrot-char (x y) (mandelbrot-iter x y - (+ (- (* x x) (* y y)) x) (+ (* 2 x y) y) - 0)) + (+ (- (* x x) (* y y)) x) (+ (* +2 x y) y) + +0)) (defun mandelbrot (xmin xmax ymin ymax) - (for 0 24 (lambda (py) - (for 0 80 (lambda (px) + (for +0 +24 (lambda (py) + (for +0 +80 (lambda (px) (princ (mandelbrot-char - (+ (* (/ px 80) (- xmax xmin)) xmin) - (+ (* (/ py 24) (- ymax ymin)) ymin))))) + (+ (* (/ px +80) (- xmax xmin)) xmin) + (+ (* (/ py +24) (- ymax ymin)) ymin))))) (newline)))) -(mandelbrot -2.15 1.25 -1.25 1.25) -; (mandelbrot -1.5 -1.1 -0.2 0.1) +(mandelbrot -2.15 +1.25 -1.25 +1.25) +; (mandelbrot -1.5 -1.1 -0.2 +0.1) -- cgit