Browse files

Integrated R/M

  • Loading branch information...
pavpanchekha committed May 7, 2014
1 parent e1d05c8 commit 4ed608257e137aaf4c7bff7d9f5ae8d85c563d0c
Showing with 9 additions and 3 deletions.
  1. +7 −1 casio/alternative.rkt
  2. +1 −1 casio/main.rkt
  3. +1 −1 casio/rules.rkt
@@ -7,7 +7,7 @@
(require racket/pretty)
(provide (struct-out alt) make-alt alt-apply alt-rewrite-tree alt-rewrite-expression
alternative<? alternative<>? apply-changes)
alt-rewrite-rm alternative<? alternative<>? apply-changes)
(struct alt (program errors cost change prev) #:transparent
#:methods gen:custom-write
@@ -48,6 +48,12 @@
(map (curry alt-apply alt)
(rewrite-expression subtree #:destruct destruct? #:root root-loc))))
(define (alt-rewrite-rm alt #:root [root-loc '()])
(let ([subtree (location-get root-loc (alt-program alt))])
(map (curry apply-changes alt)
(map reverse
(rewrite-expression-head subtree #:root root-loc)))))
(define (alternative<>? alt1 alt2)
"Compare two alternatives; return if incomparable.
Compares first by a lattice order on points, then by program cost."
@@ -10,7 +10,7 @@
(require casio/simplify)
(define (rewrite-local-error altn loc)
(alt-rewrite-expression altn #:root loc #:destruct #t))
(alt-rewrite-rm altn #:root loc))
(define (rewrite-brute-force altn)
(alt-rewrite-tree altn))
@@ -2,7 +2,7 @@
(require casio/common)
(require casio/programs)
(provide *rules* pattern-substitute pattern-match rewrite-expression rewrite-tree change-apply (struct-out change) (struct-out rule))
(provide *rules* pattern-substitute pattern-match rewrite-expression rewrite-expression-head rewrite-tree change-apply (struct-out change) (struct-out rule))
;; Our own pattern matcher.

0 comments on commit 4ed6082

Please sign in to comment.