summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arthur A. Gleckler 2021-07-18 20:22:55 -0700
committerGravatar Arthur A. Gleckler 2021-07-18 20:23:06 -0700
commitcffa45160b97e18903a73b02be66ed689105717a (patch)
treea90d5432376b9a32d03343c1c85a7457b29de4c3
parentIgnore "Dictionaries.log". (diff)
Ignore trailing whitespace.
-rw-r--r--alist-impl.scm22
-rw-r--r--dictionaries-impl.scm2
-rw-r--r--dictionaries-test.scm86
-rw-r--r--externals.scm2
-rw-r--r--indexes.scm2
-rw-r--r--internals.scm24
-rw-r--r--plist-impl.scm12
-rw-r--r--srfi-125-impl.scm30
-rw-r--r--srfi-126-impl.scm40
-rw-r--r--srfi-225.html12
-rw-r--r--srfi-69-impl.scm26
11 files changed, 129 insertions, 129 deletions
diff --git a/alist-impl.scm b/alist-impl.scm
index 4946457..5114621 100644
--- a/alist-impl.scm
+++ b/alist-impl.scm
@@ -1,24 +1,24 @@
(define (register-alist!)
-
+
(define (alist? l)
(and (list? l)
(or (null? l)
(pair? (car l)))))
(define (alist-map! proc alist)
- (map
+ (map
(lambda (e)
(define key (car e))
(define value (cdr e))
- (cons key (proc key value)))
+ (cons key (proc key value)))
alist))
(define (alist-filter! pred alist)
(filter
(lambda (e)
- (pred (car e) (cdr e)))
+ (pred (car e) (cdr e)))
alist))
-
+
(define (alist-delete key alist)
;; find the tail of alist that will be kept
;; ie rest entries after the last entry with matched key
@@ -27,7 +27,7 @@
(lst alist))
(cond
((null? lst) tail)
- (else
+ (else
(if (equal? key (caar lst))
(loop (cdr lst) (cdr lst))
(loop tail (cdr lst)))))))
@@ -41,7 +41,7 @@
(append (reverse result/reversed) kept-tail)
(let* ((entry (car lst))
(keep? (not (equal? key (car entry))))
- (result/reversed* (if keep?
+ (result/reversed* (if keep?
(cons entry result/reversed)
result/reversed)))
(loop (cdr lst) result/reversed*))))))
@@ -51,14 +51,14 @@
(define old-key (car pair))
(define old-value (cdr pair))
(define (update new-key new-value obj)
- (cond
+ (cond
((and (eq? old-key
new-key)
(eq? old-value
new-value))
(values alist obj))
(else
- (let ((new-list
+ (let ((new-list
(alist-cons
new-key new-value
(alist-delete old-key alist))))
@@ -85,11 +85,11 @@
(define (proc* e)
(proc (car e) (cdr e)))
(for-each proc* alist))
-
+
(define (alist->alist alist)
alist)
- (register-dictionary!
+ (register-dictionary!
'dictionary? alist?
'dict-map! alist-map!
'dict-filter! alist-filter!
diff --git a/dictionaries-impl.scm b/dictionaries-impl.scm
index 29da4c4..a5473f9 100644
--- a/dictionaries-impl.scm
+++ b/dictionaries-impl.scm
@@ -9,7 +9,7 @@
(let ()
(include "plist-impl.scm")
- (register-plist!))
+ (register-plist!))
(cond-expand
((library (srfi 126))
diff --git a/dictionaries-test.scm b/dictionaries-test.scm
index 30b5708..d975c8f 100644
--- a/dictionaries-test.scm
+++ b/dictionaries-test.scm
@@ -100,9 +100,9 @@
;; intern existing
(let ()
- (define-values
- (d value)
- (dict-intern! (alist->dict '((a . b))) 'a (lambda () 'd)))
+ (define-values
+ (d value)
+ (dict-intern! (alist->dict '((a . b))) 'a (lambda () 'd)))
(test-equal 'b (dict-ref d 'a))
(test-equal 'b value))
@@ -120,38 +120,38 @@
;; update existing
(let ()
- (define d (dict-update! (alist->dict '((a . "b"))) 'a
- (lambda (value)
+ (define d (dict-update! (alist->dict '((a . "b"))) 'a
+ (lambda (value)
(string-append value "2"))
error
- (lambda (x) (string-append x "1"))))
+ (lambda (x) (string-append x "1"))))
(test-equal "b12" (dict-ref d 'a)))
;; update missing
(let ()
(define d (dict-update! (alist->dict '((a . "b"))) 'c
- (lambda (value)
+ (lambda (value)
(string-append value "2"))
(lambda () "d1")
- (lambda (x) (string-append x "1"))))
+ (lambda (x) (string-append x "1"))))
(test-equal "d12" (dict-ref d 'c))))
(test-group
"dict-update/default!"
;; update existing
(let ()
- (define d (dict-update/default! (alist->dict '((a . "b"))) 'a
- (lambda (value)
+ (define d (dict-update/default! (alist->dict '((a . "b"))) 'a
+ (lambda (value)
(string-append value "2"))
- "d1"))
+ "d1"))
(test-equal "b2" (dict-ref d 'a)))
;; update missing
(let ()
(define d (dict-update/default! (alist->dict '((a . "b"))) 'c
- (lambda (value)
+ (lambda (value)
(string-append value "2"))
- "d1"))
+ "d1"))
(test-equal "d12" (dict-ref d 'c))))
(test-group
@@ -160,18 +160,18 @@
(new-dict key value)
(dict-pop! (alist->dict '((a . b) (c . d)))))
(test-assert
- (or
+ (or
(and (equal? (dict->alist new-dict) '((c . d)))
(equal? key 'a)
(equal? value 'b))
-
+
(and (equal? (dict->alist new-dict) '((a . b)))
(equal? key 'c)
(equal? value 'd)))))
(test-group
"dict-map!"
- (define d (dict-map!
+ (define d (dict-map!
(lambda (key value)
(string-append value "2"))
(alist->dict '((a . "a") (b . "b")))))
@@ -180,7 +180,7 @@
(test-group
"dict-filter!"
- (define d (dict-filter!
+ (define d (dict-filter!
(lambda (key value)
(equal? value 'b))
(alist->dict '((a . b) (c . d)))))
@@ -188,7 +188,7 @@
(test-group
"dict-remove!"
- (define d (dict-remove!
+ (define d (dict-remove!
(lambda (key value)
(equal? value 'b))
(alist->dict '((a . b) (c . d)))))
@@ -197,9 +197,9 @@
(test-group
"dict-search!"
- ;; ignore
+ ;; ignore
(let ()
- (define-values
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b))) 'c
(lambda (insert ignore)
@@ -211,7 +211,7 @@
;; insert
(let ()
- (define-values
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b))) 'c
(lambda (insert ignore)
@@ -224,7 +224,7 @@
;; update
(let ()
- (define-values
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b))) 'a
(lambda args
@@ -236,7 +236,7 @@
;; delete
(let ()
- (define-values
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b) (c . d))) 'a
(lambda args
@@ -254,7 +254,7 @@
(test-group
"dict-for-each"
(define lst '())
- (dict-for-each
+ (dict-for-each
(lambda (key value)
(set! lst (append lst (list key value))))
(alist->dict '((a . b) (c . d))))
@@ -264,7 +264,7 @@
(test-group
"dict-count"
- (define count (dict-count
+ (define count (dict-count
(lambda (key value)
(equal? value 'b))
(alist->dict '((a . b) (c . d)))))
@@ -274,16 +274,16 @@
"dict-any"
(let ()
- (define value
- (dict-any
+ (define value
+ (dict-any
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '((a . b) (c . d)))))
(test-equal value 'foo))
(let ()
- (define value
- (dict-any
+ (define value
+ (dict-any
(lambda (key value)
(if (equal? 'e value) 'foo #f))
(alist->dict '((a . b) (c . d)))))
@@ -293,7 +293,7 @@
"dict-every"
(let ()
(define value
- (dict-every
+ (dict-every
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '((a . b) (c . b)))))
@@ -301,7 +301,7 @@
(let ()
(define value
- (dict-every
+ (dict-every
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '())))
@@ -309,7 +309,7 @@
(let ()
(define value
- (dict-every
+ (dict-every
(lambda (key value)
(if (equal? 'b value) 'foo #f))
(alist->dict '((a . b) (c . d)))))
@@ -345,7 +345,7 @@
(test-group
"dict-fold"
(define value
- (dict-fold
+ (dict-fold
(lambda (key value acc)
(append acc (list key value)))
'()
@@ -357,7 +357,7 @@
(test-group
"dict-map->list"
(define lst
- (dict-map->list
+ (dict-map->list
(lambda (key value)
(string-append (symbol->string key)
value))
@@ -376,7 +376,7 @@
(test-begin "Dictionaries")
-(test-group
+(test-group
"alist"
(include "alist-impl.scm")
(clear-registry!)
@@ -392,11 +392,11 @@
(clear-registry!)
(register-plist!)
(register-alist!)
- (do-test
- (lambda (alist)
- (apply append
- (map (lambda (pair)
- (list (car pair) (cdr pair)))
+ (do-test
+ (lambda (alist)
+ (apply append
+ (map (lambda (pair)
+ (list (car pair) (cdr pair)))
alist)))))
(cond-expand
@@ -408,7 +408,7 @@
(include "srfi-69-impl.scm")
(clear-registry!)
(register-srfi-69!)
- (do-test (lambda (alist)
+ (do-test (lambda (alist)
(define table (make-hash-table equal?))
(for-each
(lambda (pair)
@@ -425,7 +425,7 @@
(include "srfi-125-impl.scm")
(clear-registry!)
(register-srfi-125!)
- (do-test (lambda (alist)
+ (do-test (lambda (alist)
(define table (make-hash-table equal?))
(for-each
(lambda (pair)
@@ -442,7 +442,7 @@
(include "srfi-126-impl.scm")
(clear-registry!)
(register-srfi-126!)
- (do-test (lambda (alist)
+ (do-test (lambda (alist)
(define table (make-eqv-hashtable))
(for-each
(lambda (pair)
diff --git a/externals.scm b/externals.scm
index c9b432c..1c5ffe8 100644
--- a/externals.scm
+++ b/externals.scm
@@ -29,7 +29,7 @@
(let ((proc-name (car lst))
(proc (cadr lst)))
(define index
- (cond
+ (cond
((assoc proc-name dname-map) => cdr)
(else (error "Unrecognized procedure name" proc-name))))
(unless (procedure? proc)
diff --git a/indexes.scm b/indexes.scm
index c126c52..a5f5568 100644
--- a/indexes.scm
+++ b/indexes.scm
@@ -38,7 +38,7 @@
;;; Maps names to indexes
-(define dname-map
+(define dname-map
`((dictionary? . ,d?)
(dict-empty? . ,dempty?)
(dict-contains? . ,dcontains?)
diff --git a/internals.scm b/internals.scm
index 095a57a..d47678b 100644
--- a/internals.scm
+++ b/internals.scm
@@ -7,7 +7,7 @@
;;; Vec argument is not used except to pass to dcalls
;;; External procedures with a rest argument use a list argument here
;;; External procedures with optional arguments are not optional here
-
+
(define-syntax dcall
(syntax-rules ()
((dcall dproc vec dictionary arg ...)
@@ -26,7 +26,7 @@
(define (idict-ref vec dictionary key failure success)
(define-values
(new-dict result)
- (dcall dsearch! vec dictionary key
+ (dcall dsearch! vec dictionary key
(lambda (_ ignore)
(ignore (failure)))
(lambda (key value update _)
@@ -43,7 +43,7 @@
(let loop ((objs objs)
(dictionary dictionary))
(cond
- ((null? objs)
+ ((null? objs)
dictionary)
((null? (cdr objs))
(error "mismatch of key / values argument list" objs))
@@ -72,10 +72,10 @@
(dictionary dictionary))
(cond
((null? keylist) dictionary)
- (else (let*-values
+ (else (let*-values
(((key) (car keylist))
((new-d _) (dcall dsearch! vec dictionary key
- (lambda (_ ignore)
+ (lambda (_ ignore)
(ignore #f))
(lambda (key old-value _ delete)
(delete #f)))))
@@ -123,7 +123,7 @@
(lambda (key value)
(define new-dict
(dcall ddelete! vec dictionary (list key)))
- (cont new-dict key value))
+ (cont new-dict key value))
dictionary))))
(define empty? (dcall dempty? vec dictionary))
(if empty?
@@ -133,7 +133,7 @@
(define (idict-map! vec proc dictionary)
(error "dict-map method not defined"))
-(define (idict-filter! vec pred dictionary)
+(define (idict-filter! vec pred dictionary)
(error "dict-filter! method not defined"))
(define (idict-remove! vec pred dictionary)
@@ -198,14 +198,14 @@
dictionary)))
(define (idict-entries vec dictionary)
- (define pair
+ (define pair
(dcall dfold vec
(lambda (key value acc)
(cons (cons key (car acc))
(cons value (cdr acc))))
(cons '() '())
dictionary))
- (values (reverse (car pair))
+ (values (reverse (car pair))
(reverse (cdr pair))))
(define (idict-fold vec proc knil dictionary)
@@ -220,7 +220,7 @@
(define reverse-lst
(dcall dfold vec
(lambda (key value lst)
- (cons (proc key value) lst))
+ (cons (proc key value) lst))
'()
dictionary))
(reverse reverse-lst))
@@ -230,13 +230,13 @@
cons
dictionary))
-(define model-vec
+(define model-vec
(vector
idictionary? idict-empty? idict-contains? idict-ref
idict-ref/default idict-set! idict-adjoin! idict-delete!
idict-delete-all! idict-replace! idict-intern!
idict-update! idict-update/default! idict-pop! idict-map!
- idict-filter! idict-remove! idict-search! idict-size
+ idict-filter! idict-remove! idict-search! idict-size
idict-for-each idict-count idict-any idict-every idict-keys
idict-values idict-entries idict-fold idict-map->list
idict->alist))
diff --git a/plist-impl.scm b/plist-impl.scm
index 4baa337..262db59 100644
--- a/plist-impl.scm
+++ b/plist-impl.scm
@@ -1,5 +1,5 @@
(define (register-plist!)
-
+
(define (plist? l)
(and (list? l)
(not (null? l))
@@ -10,7 +10,7 @@
(cond
((null? pl) plist)
((null? (cdr pl)) (error "Malformed plist" plist))
- (else
+ (else
(let ((key (car pl))
(value (cadr pl))
(rest (cddr pl)))
@@ -25,7 +25,7 @@
(cond
((null? pl) (cdr head))
((null? (cdr pl)) (error "Malformed plist" plist))
- (else
+ (else
(let ((key (car pl))
(value (cadr pl))
(rest (cddr pl)))
@@ -48,7 +48,7 @@
((null? plist) #f)
((equal? key (car plist)) head)
(else (find-plist-entry key (cdr plist)))))
-
+
(define (plist-search! plist key failure success)
(define plist-head (cons #t plist))
(define (handle-success head)
@@ -83,8 +83,8 @@
(begin
(proc (car pl) (cadr pl))
(loop (cddr pl))))))
-
- (register-dictionary!
+
+ (register-dictionary!
'dictionary? plist?
'dict-map! plist-map!
'dict-filter! plist-filter!
diff --git a/srfi-125-impl.scm b/srfi-125-impl.scm
index 0527547..67da668 100644
--- a/srfi-125-impl.scm
+++ b/srfi-125-impl.scm
@@ -1,50 +1,50 @@
(define (register-srfi-125!)
-
+
(define (hash-table-set!* table . obj)
(apply hash-table-set! (cons table obj))
table)
-
+
(define (hash-table-update!* table key updater fail success)
(hash-table-update! table key updater fail success)
table)
-
+
(define (hash-table-update!/default* table key proc default)
(hash-table-update!/default table key proc default)
table)
-
+
(define (hash-table-intern!* table key failure)
(define val (hash-table-intern! table key failure))
(values table val))
-
+
(define (hash-table-pop!* table)
(if (hash-table-empty? table)
(error "popped empty dictionary")
(call-with-values
(lambda () (hash-table-pop! table))
(lambda (key value) (values table key value)))))
-
+
(define (hash-table-delete-all!* table keys)
(for-each
(lambda (key)
(hash-table-delete! table key))
keys)
table)
-
+
(define (hash-table-map!* proc table)
(hash-table-map! proc table)
table)
-
+
(define (hash-table-filter* proc table)
- (hash-table-prune!
+ (hash-table-prune!
(lambda (key value)
(not (proc key value)))
table)
table)
-
+
(define (hash-table-remove!* proc table)
(hash-table-prune! proc table)
table)
-
+
(define (hash-table-search* table key fail success)
(define (handle-success value)
(define (update new-key new-value obj)
@@ -57,16 +57,16 @@
(values table obj))
(success key value update remove))
(define (handle-fail)
- (define (ignore obj)
+ (define (ignore obj)
(values table obj))
(define (insert value obj)
(hash-table-set! table key value)
(values table obj))
(fail insert ignore))
-
+
(define default (cons #f #f))
(hash-table-ref table key handle-fail handle-success))
-
+
(register-dictionary!
'dictionary? hash-table?
'dict-empty? hash-table-empty?
@@ -82,7 +82,7 @@
'dict-map! hash-table-map!*
'dict-filter! hash-table-filter*
'dict-remove! hash-table-remove!*
- 'dict-search! hash-table-search*
+ 'dict-search! hash-table-search*
'dict-size hash-table-size
'dict-for-each hash-table-for-each
'dict-keys hash-table-keys
diff --git a/srfi-126-impl.scm b/srfi-126-impl.scm
index a7ecd51..1ba75eb 100644
--- a/srfi-126-impl.scm
+++ b/srfi-126-impl.scm
@@ -1,14 +1,14 @@
(define (register-srfi-126!)
-
+
(define (hashtable-ref* table key fail success)
(define-values (value found?) (hashtable-lookup table key))
(if found?
(success value)
(fail)))
-
+
(define (hashtable-ref/default* table key default)
(hashtable-ref table key default))
-
+
(define (hashtable-set!* table . obj)
(let loop ((obj obj))
(if (null? obj)
@@ -16,18 +16,18 @@
(begin
(hashtable-set! table (car obj) (cadr obj))
(loop (cddr obj))))))
-
+
(define (hashtable-delete-all!* table keys)
(for-each
(lambda (key)
(hashtable-delete! table key))
keys)
table)
-
+
(define (hashtable-intern!* table key default)
(define val (hashtable-intern! table key default))
(values table val))
-
+
(define (hashtable-update/default!* table key updater default)
(hashtable-update! table key updater default)
table)
@@ -38,21 +38,21 @@
(call-with-values
(lambda () (hashtable-pop! table))
(lambda (key value) (values table key value)))))
-
+
(define (hashtable-update-all!* proc table)
(hashtable-update-all! table proc)
table)
-
+
(define (hashtable-filter!* proc table)
- (hashtable-prune! table
- (lambda (key value)
+ (hashtable-prune! table
+ (lambda (key value)
(not (proc key value))))
table)
-
+
(define (hashtable-remove!* proc table)
(hashtable-prune! table proc)
table)
-
+
(define (hashtable-search* table key fail success)
(define (handle-success value)
(define (update new-key new-value obj)
@@ -65,32 +65,32 @@
(values table obj))
(success key value update remove))
(define (handle-fail)
- (define (ignore obj)
+ (define (ignore obj)
(values table obj))
(define (insert value obj)
(hashtable-set! table key value)
(values table obj))
(fail insert ignore))
-
+
(define default (cons #f #f))
(define found (hashtable-ref table key default))
(if (eq? default found)
(handle-fail)
(handle-success found)))
-
+
(define (hashtable-for-each* proc table)
(hashtable-walk table proc)
table)
-
+
(define (hashtable-map->lset* proc table)
(hashtable-map->lset table proc))
-
+
(define (hashtable-keys* table)
(vector->list (hashtable-keys table)))
-
+
(define (hashtable-values* table)
(vector->list (hashtable-values table)))
-
+
(define (hashtable-entries* table)
(call-with-values
(lambda () (hashtable-entries table))
@@ -98,7 +98,7 @@
(values
(vector->list keys)
(vector->list vals)))))
-
+
(register-dictionary!
'dictionary? hashtable?
'dict-empty? hashtable-empty?
diff --git a/srfi-225.html b/srfi-225.html
index fef8e5a..5f2703c 100644
--- a/srfi-225.html
+++ b/srfi-225.html
@@ -136,8 +136,8 @@ Otherwise, returns two values, a dictionary that contains all the associations o
<p>Here are four examples of <code>dict-search!</code>,
one for each of the four continuations:
<blockquote><pre>
- ;; ignore
- (define-values
+ ;; ignore
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b))) 'c
(lambda (insert ignore)
@@ -148,7 +148,7 @@ one for each of the four continuations:
value => 'foo
;; insert
- (define-values
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b))) 'c
(lambda (insert ignore)
@@ -160,7 +160,7 @@ one for each of the four continuations:
value => foo
;; update
- (define-values
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b))) 'a
(lambda args
@@ -171,7 +171,7 @@ one for each of the four continuations:
value => foo
;; delete
- (define-values
+ (define-values
(dict value)
(dict-search! (alist->dict '((a . b) (c . d))) 'a
(lambda args
@@ -234,7 +234,7 @@ one for each of the four continuations:
in the sample implementation; the procedures referred to are also in
that file.<p>
<blockquote><pre>
- (register-dictionary-type!
+ (register-dictionary-type!
'dictionary? alist?
'dict-map! alist-map!
'dict-filter! alist-filter!
diff --git a/srfi-69-impl.scm b/srfi-69-impl.scm
index 3f8a602..09f92d2 100644
--- a/srfi-69-impl.scm
+++ b/srfi-69-impl.scm
@@ -1,12 +1,12 @@
(define (register-srfi-69!)
-
+
(define (hash-table-ref* table key fail success)
(define default (cons #f #f))
(define found (hash-table-ref/default table key default))
(if (eq? found default)
(fail)
(success found)))
-
+
(define (hash-table-set!* table . obj)
(let loop ((obj obj))
(if (null? obj)
@@ -14,36 +14,36 @@
(begin
(hash-table-set! table (car obj) (cadr obj))
(loop (cddr obj))))))
-
+
(define (hash-table-update!/default* table key proc default)
(hash-table-update!/default table key proc default)
table)
-
+
(define (hash-table-delete-all!* table keys)
(for-each
(lambda (key)
(hash-table-delete! table key))
keys)
table)
-
+
(define (hash-table-foreach* proc table)
(hash-table-walk table proc))
-
+
(define (hash-table-map* proc table)
(hash-table-walk table (lambda (key value)
(hash-table-set! table key (proc key value))))
table)
-
+
(define (hash-table-filter* proc table)
- (hash-table-walk table
+ (hash-table-walk table
(lambda (key value)
(unless (proc key value)
(hash-table-delete! table key))))
table)
-
+
(define (hash-table-fold* proc knil table)
(hash-table-fold table proc knil))
-
+
(define (hash-table-search* table key fail success)
(define (handle-success value)
(define (update new-key new-value obj)
@@ -56,19 +56,19 @@
(values table obj))
(success key value update remove))
(define (handle-fail)
- (define (ignore obj)
+ (define (ignore obj)
(values table obj))
(define (insert value obj)
(hash-table-set! table key value)
(values table obj))
(fail insert ignore))
-
+
(define default (cons #f #f))
(define found (hash-table-ref/default table key default))
(if (eq? default found)
(handle-fail)
(handle-success found)))
-
+
(register-dictionary!
'dictionary? hash-table?
'dict-ref hash-table-ref*