From 69eed25e80ccb076117152d2defe33bb01eefc79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Wed, 15 Mar 2023 12:47:47 +0100 Subject: [PATCH] 4digit string recognition --- members-base.scm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/members-base.scm b/members-base.scm index e27bd83..eeabd8e 100644 --- a/members-base.scm +++ b/members-base.scm @@ -38,6 +38,7 @@ (chicken file posix) (chicken file) (chicken format) + (chicken irregex) testing utils dictionary) @@ -95,9 +96,22 @@ name)) (+ errs 1)))))))) + ;; Checks whether given string is a 4-digit decimal number. + (define (is-4digit-string? s) + (if (irregex-search (irregex "^[0-9]{4}$") s) + #t + #f)) + + ;; Returns dictionary containing only records with either 4-digit + ;; name or one of its aliases being 4-digit. + (define (files-dictionary-filter-4digit d) + d) + (define (load-members dn) ;; get the directory contents - (print (files+symlinks->files-dictionary (get-files+symlinks dn))) + (let ((fss (files+symlinks->files-dictionary + (get-files+symlinks dn)))) + (print (map length fss))) ;; filter all ids ;; resolve links (it might be unknown!) ;; load member files @@ -117,6 +131,9 @@ (666 . nonexistent))) '((nonexistent error-0 666) (joe 2803))) + (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")) )) )