simplified using scheme control constructs

This commit is contained in:
2021-12-08 01:22:28 +01:00
parent c166d1dada
commit e4ee931c08

View File

@@ -44,13 +44,7 @@
; returns the largest value obtained while applying pick to each element of lst
(define (get-max lst pick)
(let loop [(m 0)
(lst lst)]
(if (null? lst)
m
[loop
(max m (pick (car lst)))
(cdr lst)])))
(apply max (map pick lst)))
(define (sign value)
(cond
@@ -95,10 +89,10 @@
(let* [(width (+ 1 (get-max lines get-max-x)))
(height (+ 1 (get-max lines get-max-y)))
(image (make-image width height))]
(let loop! [(lines lines)]
(when (not (null? lines))
(additively-rasterize-line! image (car lines) allow-diagonals)
(loop! (cdr lines))))
(for-each
(lambda (line)
(additively-rasterize-line! image line allow-diagonals))
lines)
image))
; count pixels with value strictly higher than 1