Created
July 2, 2015 07:53
-
-
Save wobh/3fae92e1077c1ba05f14 to your computer and use it in GitHub Desktop.
Near alphabetic standard characters
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 char-next (char) | |
"Return the next alphabetic character, per CL standard." | |
(assert (char-lessp char #\Z) | |
(char) "No further characters in the standard alphabet.") | |
(let* ((char-num (digit-char-p (char-upcase char) 36)) | |
(char-next (digit-char (1+ char-num) 36))) | |
(if (lower-case-p char) | |
(char-downcase char-next) | |
char-next))) | |
(defun char-prev (char) | |
"Return the next alphabetic character, per CL standard." | |
(assert (char-greaterp char #\A) | |
(char) "No previous characters in the standard alphabet.") | |
(let* ((char-num (digit-char-p (char-upcase char) 36)) | |
(char-prev (digit-char (1- char-num) 36))) | |
(if (lower-case-p char) | |
(char-downcase char-next) | |
char-next))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment