Matthew Butterick 7 years ago
parent 8581321a90
commit 7bfe789c51

@ -8,5 +8,5 @@
(entrance-point quad)
(exit-point quad)
(inner-point quad)
(size quad)
(draw quad))
(size quad [condition])
(draw quad [surface] [origin]))

@ -10,8 +10,8 @@
(define (entrance-point q) (hash-ref (attrs q) 'entrance 'entrance))
(define (exit-point q) (hash-ref (attrs q) 'exit 'exit))
(define (inner-point q) (hash-ref (attrs q) 'inner 'inner))
(define (size q) (length (elems q)))
(define (draw q) "<···>")])
(define (size q [condition #f]) (hash-ref (attrs q) 'size (λ () (length (elems q)))))
(define (draw q [surface #f] [origin #f]) ((hash-ref (attrs q) 'draw (λ () (λ () (println "<no draw routine>"))))))])
(define (quad-attrs? x) (and (hash? x) (hash-eq? x)))
(define (quad-elem? x) (or (char? x) (string? x) ($quad? x)))
@ -37,3 +37,10 @@
(define (break . xs) (apply quad #:type $break xs))
(define b break)
(module+ test
(define x ($quad (hasheq 'entrance 0
'exit 10+10i
'inner 5+5i
'size 8+8i
'draw (λ () (println "foo"))) '(#\H #\e #\l #\o)))
(draw x))
Loading…
Cancel
Save