Last active
August 29, 2015 14:13
-
-
Save dvnmk/653f13e54707c13bed46 to your computer and use it in GitHub Desktop.
"aBcDe -> AbCdE"
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) | |
""aBcDe1" -> "AbCdE1"" | |
(do* ((i 0 (+ i 1)) | |
(len (length string)) | |
(res string)) | |
((equal i len) res) | |
(let ((ele (aref string i))) | |
(if (< (char-code ele) 91) ; ascii A 65 ~ Z 90, a 97 ~ z 122 | |
(setf (aref string i) (char-downcase ele)) | |
(setf (aref string i) (char-upcase ele)))))) | |
(toggle-case "aBcDe3") | |
"AbCdE3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment