Quick hack to display picts in the DrRacket REPL
This commit is contained in:
parent
f68eb51365
commit
e2154543c5
|
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -10,4 +10,4 @@ Graphics({Hue(0),Point({0,0}),Hue(1/3),Point({3,0}),Hue(2/3),Point({6,0})});
|
|||
|
||||
Graphics({Line({10,10},{20,20},{20,30},{30,30}),
|
||||
Point({10,10})});
|
||||
Graphics(AppendStar(Map((λx.{Hue(x/(2*pi)),Point({8*Sin(2*x),8*Cos(3*x)})}),Range(0,2*pi,1/128))))
|
||||
Graphics(AppendStar(Map((λ x.{Hue(x/(2*pi)),Point({8*Sin(2*x),8*Cos(3*x)})}),Range(0,2*pi,1/128))))
|
||||
|
|
|
@ -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,16 +34,21 @@
|
|||
(unparse-sum form first? level-below-times?))
|
||||
|
||||
(define (unparse-sum form [first? #t] [level-below-times? #f])
|
||||
(case (operator form)
|
||||
[(Plus)
|
||||
(define ops (operands form))
|
||||
(define unwrapped
|
||||
(string-append*
|
||||
(maybe-add-between (map unparse-product ops) "+" #\-)))
|
||||
(wrap-if (and level-below-times? (>= (length ops) 2))
|
||||
unwrapped)]
|
||||
[else
|
||||
(unparse-product form first? level-below-times?)]))
|
||||
(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))
|
||||
(define unwrapped
|
||||
(string-append*
|
||||
(maybe-add-between (map unparse-product ops) "+" #\-)))
|
||||
(wrap-if (and level-below-times? (>= (length ops) 2))
|
||||
unwrapped)]
|
||||
[else
|
||||
(unparse-product form first? level-below-times?)])))
|
||||
|
||||
(define (wrap-if test str)
|
||||
(if test (string-append "(" str ")") str))
|
||||
|
@ -135,7 +141,7 @@
|
|||
(define x 'x)
|
||||
(define y 'y)
|
||||
(define z 'z)
|
||||
|
||||
|
||||
(displayln "TEST - Running tests in unparse.rkt")
|
||||
|
||||
;;; Numbers
|
||||
|
|
Loading…
Reference in New Issue
Block a user