Lists of symbols - 4-digit checking.

This commit is contained in:
Dominik Pantůček 2023-03-15 12:55:44 +01:00
parent 69eed25e80
commit 0e5b59cab0

View file

@ -102,9 +102,23 @@
#t #t
#f)) #f))
;; checks whether given symbol is a 4-digit one.
(define (is-4digit-symbol? s)
(is-4digit-string?
(symbol->string s)))
;; Returns true if the list contains at least one 4-digit symbol.
(define (list-contains-4digit-symbol? lst)
(let loop ((lst lst))
(if (null? lst)
#f
(if (is-4digit-symbol? (car lst))
#t
(loop (cdr lst))))))
;; Returns dictionary containing only records with either 4-digit ;; Returns dictionary containing only records with either 4-digit
;; name or one of its aliases being 4-digit. ;; name or one of its aliases being 4-digit.
(define (files-dictionary-filter-4digit d) (define (files-dictionary-filter-4digit-symbols d)
d) d)
(define (load-members dn) (define (load-members dn)
@ -134,6 +148,10 @@
(test-true is-4digit-string? (is-4digit-string? "0000")) (test-true is-4digit-string? (is-4digit-string? "0000"))
(test-false is-4digit-string? (is-4digit-string? "AAAA")) (test-false is-4digit-string? (is-4digit-string? "AAAA"))
(test-false is-4digit-string? (is-4digit-string? "666")) (test-false is-4digit-string? (is-4digit-string? "666"))
(test-true is-4digit-symbol? (is-4digit-symbol? '|0000|))
(test-false is-4digit-symbol? (is-4digit-symbol? '|ABC|))
(test-true list-contains-4digit-symbol? (list-contains-4digit-symbol? '(|0000| abc |666|)))
(test-false list-contains-4digit-symbol? (list-contains-4digit-symbol? '(|00000| abc |666|)))
)) ))
) )