mutational flatten

main
Matthew Butterick 4 years ago
parent 4a23ca67a7
commit d1e81308d6

@ -128,8 +128,9 @@
[(list ∆x ∆y) (sqrt (+ (expt ∆x 2) (expt ∆y 2)))])) [(list ∆x ∆y) (sqrt (+ (expt ∆x 2) (expt ∆y 2)))]))
(define (flatten-quad q) (define (flatten-quad q)
(cons (struct-copy quad q [elems null]) (define elems (quad-elems q))
(apply append (map flatten-quad (quad-elems q))))) (cons (quad-update! q [elems null])
(apply append (map flatten-quad elems))))
(define (bounding-box . qs-in) (define (bounding-box . qs-in)
;; size of box that holds q and all subqs, based on reported origin and size ;; size of box that holds q and all subqs, based on reported origin and size

Loading…
Cancel
Save