Skip to content

Commit

Permalink
Add paren around negativ numbers and mulitple interms around an integ…
Browse files Browse the repository at this point in the history
…rand.
  • Loading branch information
soegaard committed Oct 3, 2023
1 parent f5cced2 commit 331c211
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions racket-cas/format.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,16 @@
[(list 'bar u) (~a "\\bar{" (v~ u) "}")] ; TODO: only for TeX
[(list* 'braces us) (apply ~a (append (list "\\{") (add-between (map v~ us) ",") (list "\\}")))] ; TODO: only for TeX
[(list* 'bracket us) (apply ~a (append (list "[") (add-between (map v~ us) ",") (list "]")))] ; TODO: only for TeX
[(list 'int u v) (~a "\\int " (v~ u) "\\ \\textrm{d}" (v~ v))] ; TODO: only for TeX

[(list 'int u v) (cond
[(or (and (number? u) (negative? u))
(match u
[(list '* u0 ...) (and (number? u0) (negative? u0))]
[(list (or '+ '-) _ ...) #t]
[_ #f]))
(~a "\\int " (v~ `(paren ,u)) "\\ \\textrm{d}" (v~ v))]
[else
(~a "\\int " (v~ u) "\\ \\textrm{d}" (v~ v))])] ; TODO: only for TeX

; applications
[(app: f us) (let ()
Expand Down Expand Up @@ -963,7 +972,15 @@
[(list 'bar u) (~a "\\bar{" (v~ u) "}")] ; TODO: only for TeX
[(list 'where u v) (~a (v~ u) " | " (v~ v))] ; TODO: only for TeX

[(list 'int u v) (~a "\\int " (v~ u) "\\ \\textrm{d}" (v~ v))] ; TODO: only for TeX
[(list 'int u v) (cond
[(or (and (number? u) (negative? u))
(match u
[(list '* u0 ...) (and (number? u0) (negative? u0))]
[(list (or '+ '-) _ ...) #t]
[_ #f]))
(~a "\\int " (v~ `(paren ,u)) "\\ \\textrm{d}" (v~ v))]
[else
(~a "\\int " (v~ u) "\\ \\textrm{d}" (v~ v))])] ; TODO: only for TeX

[(list* 'braces us) (apply ~a (append (list "\\{") (add-between (map v~ us) ",") (list "\\}")))] ; TODO: only for TeX
[(list* 'bracket us) (apply ~a (append (list "[") (add-between (map v~ us) ",") (list "]")))] ; TODO: only for TeX
Expand Down

0 comments on commit 331c211

Please sign in to comment.