Skip to content

Instantly share code, notes, and snippets.

@laynor
Last active December 22, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laynor/6521564 to your computer and use it in GitHub Desktop.
Save laynor/6521564 to your computer and use it in GitHub Desktop.
split word at case change
(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