Quick hack to display picts in the DrRacket REPL

This commit is contained in:
Jens Axel Søgaard 2013-04-07 22:55:15 +02:00
parent f68eb51365
commit e2154543c5
3 changed files with 23 additions and 14 deletions

View File

@ -21,7 +21,10 @@
(current-print
(λ (val)
(unless (void? val)
(displayln (unparse val)))))
(define u (unparse val))
(if (string? u)
(displayln u)
(old-print u))))) ; pict hack
)

View File

@ -7,7 +7,8 @@
(require (submod "bracket.rkt" expression-core)
(submod "bracket.rkt" equation-expression)
(submod "bracket.rkt" bracket))
(submod "bracket.rkt" bracket)
slideshow/pict)
(define (map/first? base f xs)
@ -33,6 +34,11 @@
(unparse-sum form first? level-below-times?))
(define (unparse-sum form [first? #t] [level-below-times? #f])
(if (pict? form)
form ; hack: A single pict is returned as is
; The unparse functions needs to return
; something else than just strings in order
; support other values such as snips.
(case (operator form)
[(Plus)
(define ops (operands form))
@ -42,7 +48,7 @@
(wrap-if (and level-below-times? (>= (length ops) 2))
unwrapped)]
[else
(unparse-product form first? level-below-times?)]))
(unparse-product form first? level-below-times?)])))
(define (wrap-if test str)
(if test (string-append "(" str ")") str))