Permalink
Browse files

Bug fix and added some rewrite rules.

  • Loading branch information...
pavpanchekha committed Nov 5, 2013
1 parent a1e6a84 commit 8ea39583fc251eedd928dc1c35f016f794ccad02
Showing with 5 additions and 2 deletions.
  1. +5 −2 casio.rkt
View
@@ -198,7 +198,7 @@
"Measures how good a program is; lower is better. Returns a list, to be sorted with list<."
(list
(+ (* 0.1 (alternative-specials alt))
(log (alternative-error alt))
(log (max (alternative-error alt) 1e-50))
(* 0.005 (alternative-cost alt)))
(alternative-error alt)
(alternative-specials alt)
@@ -242,7 +242,10 @@
(define (rewrite-rules var expr)
(recursive-match expr
;[`(list - ,x ,x) 0]
;[`(+ ,a (+ ,b ,c)) `(+ (+ ,a ,b) ,c)]
[`(+ ,a (+ ,b ,c)) `(+ (+ ,a ,b) ,c)]
[`(+ (+ ,a ,b) ,c) `(+ ,a (+ ,b ,c))]
[`(* ,a (+ ,b ,c)) `(+ (* ,a ,b) (* ,a ,c))]
[`(+ (* ,a ,b) (* ,a ,c)) `(* ,a (+ ,b ,c))]
[x `(exp (log ,x))]
[x `(log (exp ,x))]))
;[`(/ (+ ,x (sqrt ,y)) ,c) `(/ (- (expt ,x 2) ,y) (* ,c (- ,x (sqrt ,y))))]))

0 comments on commit 8ea3958

Please sign in to comment.