Skip to content

Commit

Permalink
A little more stylistic compression finally wins the page.
Browse files Browse the repository at this point in the history
I don't know why I try so hard for this.
  • Loading branch information
axch committed May 23, 2013
1 parent 507d4ec commit 8c14fde
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions term-rewriting.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@

;;;; Term rewriting

;;; Make a term-rewriting system from a collection of rules. This is
;;; just a facade for a particular rule application strategy chosen
;;; from the combinators below.

(define (term-rewriting . rules)
(rule-simplifier rules))
;;; Make a term-rewriting system from a list of rules. This is a
;;; facade for a rule application strategy from the combinators below.

(define (term-rewriting . rules) (rule-simplifier rules))
(define (rule-simplifier the-rules)
(iterated-on-subexpressions (rule-list the-rules)))

Expand All @@ -47,14 +44,13 @@
(if (eqv? data answer)
(per-rule (cdr rules))
answer)))))


;; Apply several rules in series, threading the results.
(define ((in-order . the-rules) datum)
(let loop ((datum datum) (the-rules the-rules))
(if (null? the-rules)
datum
(loop ((car the-rules) datum) (cdr the-rules)))))

(loop ((car the-rules) datum) (cdr the-rules)))))
;; Apply one rule repeatedly until it doesn't match anymore.
(define ((iterated the-rule) data)
(let loop ((data data) (answer (the-rule data)))
Expand Down

0 comments on commit 8c14fde

Please sign in to comment.