Skip to content

Commit

Permalink
I think it is really important for the published interface of the
Browse files Browse the repository at this point in the history
matcher procedures to return standard Scheme alists rather than lists
of two-element lists, regardless of how badly they pretty-print.
  • Loading branch information
axch committed May 23, 2013
1 parent 04ccad2 commit 203dfa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions patterns.scm
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
(define (dict:value vcell)
(interpret-segment (cadr vcell)))

(define (dictionary->entry-list dict)
(define (dictionary->alist dict)
(map (lambda (entry)
(list (car entry) (interpret-segment (cadr entry))))
(cons (car entry) (interpret-segment (cadr entry))))
dict))

;;; Segment variables introduce some additional trouble. Unlike other
Expand Down Expand Up @@ -264,7 +264,7 @@
(matcher
datum '()
(lambda (dict)
(dictionary->entry-list dict)))))
(dictionary->alist dict)))))

(define (for-each-matcher pattern)
(for-each-dictionary (match:->combinators pattern)))
Expand All @@ -274,7 +274,7 @@
(matcher
datum '()
(lambda (dict)
(f (dictionary->entry-list dict))
(f (dictionary->alist dict))
#f))))

(define (all-results-matcher pattern)
Expand Down
12 changes: 6 additions & 6 deletions test/patterns-test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
(lambda (x) `(succeed ,x))))

(equal?
'(((y (b b b b b b)) (x ()))
((y (b b b b)) (x (b)))
((y (b b)) (x (b b)))
((y ()) (x (b b b))))
'(((y . (b b b b b b)) (x . ()))
((y . (b b b b)) (x . (b)))
((y . (b b)) (x . (b b)))
((y . ()) (x . (b b b))))
((all-dictionaries
(match:->combinators '(a (?? x) (?? y) (?? x) c)))
'(a b b b b b b c)))
Expand All @@ -58,7 +58,7 @@
'(a b b b b b b a)))

(equal?
'((b 1))
'((b . 1))
((matcher '(a ((? b) 2 3) (? b) c))
'(a (1 2 3) 1 c))))

Expand All @@ -85,7 +85,7 @@
(match:->combinators '(and (?? stuff))))
(let ((items (iota 10))) ; constant time, except building the test list
(assert-equal
`(((stuff ,items)))
`(((stuff . ,items)))
((all-dictionaries matcher)
`(and ,@items)))))
)

0 comments on commit 203dfa9

Please sign in to comment.