Move capitalize to util-string.
This commit is contained in:
parent
fb47d60550
commit
27a1a3522b
2 changed files with 22 additions and 9 deletions
|
@ -282,13 +282,6 @@
|
|||
(print " " (car keys) ": " (length (ldict-ref status (car keys)))))
|
||||
(loop (cdr keys)))))))
|
||||
|
||||
(define (capitalize s)
|
||||
(let ((l (string->list s)))
|
||||
(list->string
|
||||
(cons
|
||||
(char-upcase (car l))
|
||||
(map char-downcase (cdr l))))))
|
||||
|
||||
(define* (check-mailing-list mls name #:pred? (pred? #f))
|
||||
(define ml (find-mailman-list mls name))
|
||||
(let-values (((missing surplus)
|
||||
|
@ -301,9 +294,9 @@
|
|||
(print "Skipping ML check - not loaded")
|
||||
(if (and (null? missing)
|
||||
(null? surplus))
|
||||
(print (format "~a mailing list membership in sync." (capitalize name)))
|
||||
(print (format "~a mailing list membership in sync." (string-capitalize name)))
|
||||
(let ()
|
||||
(print (format "~a mailing list:" (capitalize name)))
|
||||
(print (format "~a mailing list:" (string-capitalize name)))
|
||||
(when (not (null? missing))
|
||||
(print " Missing: " missing))
|
||||
(when (not (null? surplus))
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
string-upcase
|
||||
|
||||
string-capitalize
|
||||
|
||||
string-tests!
|
||||
)
|
||||
|
||||
|
@ -100,6 +102,18 @@ using ```char-upcase```. Does not work with UTF-8.")
|
|||
(map char-upcase
|
||||
(string->list str))))
|
||||
|
||||
(define/doc (string-capitalize str)
|
||||
("* ```str``` - arbitrary string
|
||||
|
||||
Returns the ```str``` with the first character converted to upper case
|
||||
using ```char-upcase``` and the remainder converted to lower case
|
||||
using ```char-downcase```. Does not work with UTF-8.")
|
||||
(let ((l (string->list str)))
|
||||
(list->string
|
||||
(cons
|
||||
(char-upcase (car l))
|
||||
(map char-downcase (cdr l))))))
|
||||
|
||||
;; Performs utils module self-tests.
|
||||
(define (string-tests!)
|
||||
(run-tests
|
||||
|
@ -122,6 +136,12 @@ using ```char-upcase```. Does not work with UTF-8.")
|
|||
(test-equal? string-upcase
|
||||
(string-upcase "asdFGH")
|
||||
"ASDFGH")
|
||||
(test-equal? string-capitalize
|
||||
(string-capitalize "asdf")
|
||||
"Asdf")
|
||||
(test-equal? string-capitalize
|
||||
(string-capitalize "ASDF")
|
||||
"Asdf")
|
||||
))
|
||||
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue