From 0e5b59cab028f24cf346f731c08fea12da762d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Wed, 15 Mar 2023 12:55:44 +0100 Subject: [PATCH] Lists of symbols - 4-digit checking. --- members-base.scm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/members-base.scm b/members-base.scm index eeabd8e..c0788ae 100644 --- a/members-base.scm +++ b/members-base.scm @@ -102,9 +102,23 @@ #t #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 ;; name or one of its aliases being 4-digit. - (define (files-dictionary-filter-4digit d) + (define (files-dictionary-filter-4digit-symbols d) d) (define (load-members dn) @@ -134,6 +148,10 @@ (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? "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|))) )) )