Skip to content

Instantly share code, notes, and snippets.

@wobh
Created July 2, 2015 07:53
Show Gist options
  • Save wobh/3fae92e1077c1ba05f14 to your computer and use it in GitHub Desktop.
Save wobh/3fae92e1077c1ba05f14 to your computer and use it in GitHub Desktop.
Near alphabetic standard 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