Skip to content

Commit

Permalink
fix number recognition bug reported by Will Byrd
Browse files Browse the repository at this point in the history
  • Loading branch information
mfelleisen committed Jun 20, 2019
1 parent c83ca4c commit 13f0039
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion task-2.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
(define ((callback setter) field _evt)
(send field set-field-background (make-object color% "white"))
(define field:num (string->number (send field get-value)))
(if field:num (setter field:num) (send field set-field-background (make-object color% "red"))))
(cond
[(and field:num (rational? field:num))
(define inexact-n (* #i1.0 field:num))
(setter inexact-n)
(send field set-value (~r inexact-n #:precision 4))]
[else (send field set-field-background (make-object color% "red"))]))

(define-syntax-rule (flow *from --> *to to-field)
(λ (x)
Expand Down

0 comments on commit 13f0039

Please sign in to comment.