Created
January 20, 2015 13:08
-
-
Save dvnmk/b63dcd75581f52eb9226 to your computer and use it in GitHub Desktop.
"aBcDe2" -> "AbCdE2"
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
(defun toggle-case (string) | |
""aBcDe" -> "AbCdE"" | |
(do* ((i 0 (+ i 1)) | |
(len (length string)) | |
(res string)) | |
((equal i len) res) | |
(let ((ele (aref string i))) | |
(if (< ele 91) ; ascii A 65 ~ Z 90, a 97 ~ z 122 | |
(aset string i (downcase ele)) | |
(aset string i (upcase ele)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment