;; lower case or capitalized. This is a very general definition of
;; capitalization; if you need something more specific you should
;; call this procedure on the individual words.
- (letrec
- ((find-first-word
- (lambda (start)
- (and (fix:< start end)
- (let ((char (string-ref string start)))
- (if (char-upper-case? char)
- (scan-word-tail (fix:+ start 1))
- (and (not (char-lower-case? char))
- (find-first-word (fix:+ start 1))))))))
- (scan-word-tail
- (lambda (start)
- (or (fix:= start end)
- (let ((char (string-ref string start)))
- (if (char-lower-case? char)
- (scan-word-tail (fix:+ start 1))
- (and (not (char-upper-case? char))
- (find-subsequent-word (fix:+ start 1))))))))
- (find-subsequent-word
- (lambda (start)
- (or (fix:= start end)
- (let ((char (string-ref string start)))
- (if (char-alphabetic? char)
- (scan-word-tail (fix:+ start 1))
- (find-subsequent-word (fix:+ start 1))))))))
- (find-first-word start)))
+ (define (find-first-word start)
+ (and (fix:< start end)
+ (let ((char (string-ref string start)))
+ (if (char-upper-case? char)
+ (scan-word-tail (fix:+ start 1))
+ (and (not (char-lower-case? char))
+ (find-first-word (fix:+ start 1)))))))
+ (define (scan-word-tail start)
+ (or (fix:= start end)
+ (let ((char (string-ref string start)))
+ (if (char-lower-case? char)
+ (scan-word-tail (fix:+ start 1))
+ (and (not (char-upper-case? char))
+ (find-subsequent-word (fix:+ start 1)))))))
+ (define (find-subsequent-word start)
+ (or (fix:= start end)
+ (let ((char (string-ref string start)))
+ (if (char-alphabetic? char)
+ (scan-word-tail (fix:+ start 1))
+ (find-subsequent-word (fix:+ start 1))))))
+ (find-first-word start))
(define (string-capitalize string)
(guarantee-string string 'STRING-CAPITALIZE)