From 7bfe789c51903db14922a6391b644883daed2b89 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 15 Feb 2018 00:11:16 -0800 Subject: [PATCH] z --- quad/quad/generic.rkt | 4 ++-- quad/quad/quad.rkt | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/quad/quad/generic.rkt b/quad/quad/generic.rkt index c862247a..cd1ea66c 100644 --- a/quad/quad/generic.rkt +++ b/quad/quad/generic.rkt @@ -8,5 +8,5 @@ (entrance-point quad) (exit-point quad) (inner-point quad) - (size quad) - (draw quad)) \ No newline at end of file + (size quad [condition]) + (draw quad [surface] [origin])) \ No newline at end of file diff --git a/quad/quad/quad.rkt b/quad/quad/quad.rkt index 5de18d84..9133b6c1 100644 --- a/quad/quad/quad.rkt +++ b/quad/quad/quad.rkt @@ -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 ""))))))]) (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)) \ No newline at end of file