Last active
June 9, 2017 02:47
-
-
Save Lifelovinglight/baa4ce77bacfb82f71e65d0575c73c91 to your computer and use it in GitHub Desktop.
:PPP
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 convert (string) | |
(let ((designators '(("0y" . 2) | |
("0o" . 8) | |
("0x" . 16)))) | |
(cond ((string= "" string) 0) | |
((every #'digit-char-p string) | |
(parse-integer string)) | |
((> (length string) 2) | |
(parse-integer string | |
:start 2 | |
:radix (cdr (assoc (subseq string 0 2) | |
designators | |
:test #'string=)))) | |
(t (error (format nil "Illegal base designation in ~a" string)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment