Use lists instead of sets in diff.rkt to reduce consing slightly

This commit is contained in:
Tony Garnock-Jones 2014-12-23 22:00:31 -05:00
parent 29be136d06
commit 7b7676b1ab
1 changed files with 2 additions and 2 deletions

View File

@ -15,7 +15,7 @@
(for/fold [(classes (hash))]
[(i (in-naturals))
(item xs)]
(hash-set classes item (set-add (hash-ref classes item (lambda () (set))) i))))
(hash-set classes item (cons i (hash-ref classes item '())))))
(struct candidate (x-index y-index chain) #:prefab)
@ -27,7 +27,7 @@
(define r 0)
(define c (hash-ref candidates 0))
(let/ec break
(for ((j (in-set (hash-ref ys-equivalence-classes item (lambda () (set))))))
(for ((j (in-list (reverse (hash-ref ys-equivalence-classes item '())))))
;; j names an index into ys
(define s (let loop ((s r))
(cond