Last active
December 22, 2015 19:39
-
-
Save laynor/6521564 to your computer and use it in GitHub Desktop.
split word at case change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (camlCaseSplit (str0 :: <str>)) | |
(let ((word (<builder>)) | |
(l (str0:length)) | |
(pack ())) | |
(do ((i 0 (+ i 1))) | |
((>= i l)) | |
(let ((c (string-ref str0 i))) | |
(if (char-upper-case? c) | |
(begin | |
(set! pack (cons (! to-string word) pack)) | |
(set! word (<builder>)))) | |
(let ((cs (String c))) | |
(word:append (as <str> cs))))) | |
(set! pack (cons word pack)) | |
(reverse pack))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment