Split out member-record module.
This commit is contained in:
parent
fcf9b57f8d
commit
023befa8f8
4 changed files with 111 additions and 60 deletions
|
@ -33,6 +33,7 @@
|
|||
find-member-by-nick
|
||||
list-members-ids
|
||||
list-members-nicks
|
||||
print-members-base-info
|
||||
members-base-tests!
|
||||
)
|
||||
|
||||
|
@ -43,10 +44,13 @@
|
|||
(chicken file)
|
||||
(chicken format)
|
||||
(chicken irregex)
|
||||
(chicken sort)
|
||||
(chicken string)
|
||||
testing
|
||||
utils
|
||||
dictionary
|
||||
member-file)
|
||||
member-file
|
||||
primes)
|
||||
|
||||
;; Gets all files and symbolic links from given directory. The
|
||||
;; symbolic links are represented by cons cells with car being the
|
||||
|
@ -221,6 +225,28 @@
|
|||
(define (list-members-nicks mb)
|
||||
(map (lambda (mr) (dict-ref (dict-ref mr 'info) 'nick)) mb))
|
||||
|
||||
;; Basic information about members-base in human-readable form.
|
||||
(define (print-members-base-info mb)
|
||||
(let ((nicks (list-members-nicks mb))
|
||||
(ids (list-members-ids mb)))
|
||||
(print "Members ("
|
||||
(length nicks)
|
||||
"): "
|
||||
(string-intersperse
|
||||
(sort
|
||||
nicks
|
||||
string<?)
|
||||
", "))
|
||||
(print "Total IDs: "
|
||||
(length ids)
|
||||
" (" (length (filter is-4digit-prime? ids)) " valid)")
|
||||
(let ((invalid-ids (filter (compose not is-4digit-prime?) ids)))
|
||||
(when (not (null? invalid-ids))
|
||||
(print " Invalid (" (length invalid-ids) "): "
|
||||
(string-intersperse
|
||||
(map number->string invalid-ids)
|
||||
", "))))))
|
||||
|
||||
;; Performs self-tests of this module.
|
||||
(define (members-base-tests!)
|
||||
(run-tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue