gscheme/examples/parse-error2.scm

29 lines
692 B
Scheme

(define koch
(let ((s (/ (sqrt 3) 2 3)))
(lambda (res depth)
(letrec
((iter
(lambda (x1 y1 x2 y2 d)
(if (zero? d)
(draw-line x2 y2)
(let* ((dx (- x2 x1))
(dy (- y2 y1))
(^ test)
(thx (+ x1 (/ dx 3)))
(thy (+ y1 (/ dy 3)))
(thx2 (+ x1 (* 2 (/ dx 3))))
(thy2 (+ y1 (* 2 (/ dy 3))))
(mx (/ (+ x1 x2) 2))
(my (/ (+ y1 y2) 2))
(midx (+ mx (* (- dy) s)))
(midy (+ my (* dx s))))
(iter x1 y1 thx thy (- d 1))
(iter thx thy midx midy (- d 1))
(iter midx midy thx2 thy2 (- d 1))
(iter thx2 thy2 x2 y2 (- d 1)))))))
(draw-move 0 0)
(draw-color 0 255 0)
(iter 0 0 res 0 depth)))))
(koch 200 4)