Implement ldict-empty? predicate.
This commit is contained in:
parent
6d3d7079cf
commit
920fab2b83
2 changed files with 17 additions and 0 deletions
|
@ -49,6 +49,12 @@ populating it with initial data.
|
||||||
If only one argument is given, the procedure checks whether it is a
|
If only one argument is given, the procedure checks whether it is a
|
||||||
list of equality procedure and acts accordingly.
|
list of equality procedure and acts accordingly.
|
||||||
|
|
||||||
|
(ldict-empty? d)
|
||||||
|
|
||||||
|
* ```d``` - a ldict instance
|
||||||
|
|
||||||
|
Returns true if given dictionary contains no keys.
|
||||||
|
|
||||||
### IO
|
### IO
|
||||||
|
|
||||||
(import util-io)
|
(import util-io)
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
TAG-LDICT
|
TAG-LDICT
|
||||||
|
|
||||||
make-ldict
|
make-ldict
|
||||||
|
|
||||||
|
ldict-empty?
|
||||||
|
|
||||||
ldict-has-key?
|
ldict-has-key?
|
||||||
ldict-ref
|
ldict-ref
|
||||||
|
@ -71,6 +73,15 @@
|
||||||
(loop (ldict-set ld (caar pairs) (cdar pairs))
|
(loop (ldict-set ld (caar pairs) (cdar pairs))
|
||||||
(cdr pairs))))))
|
(cdr pairs))))))
|
||||||
|
|
||||||
|
;; Convenience accessors
|
||||||
|
(define ldict-meta cadr)
|
||||||
|
(define ldict-equality? caadr)
|
||||||
|
(define ldict-list cddr)
|
||||||
|
|
||||||
|
;; Returns true if given dictionary contains no keys
|
||||||
|
(define (ldict-empty? d)
|
||||||
|
(null? (ldict-list d)))
|
||||||
|
|
||||||
;; Checks whether given dictionary d contains the key k.
|
;; Checks whether given dictionary d contains the key k.
|
||||||
(define (dict-has-key? d k)
|
(define (dict-has-key? d k)
|
||||||
(if (assq k d) #t #f))
|
(if (assq k d) #t #f))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue