Skip to content

Instantly share code, notes, and snippets.

@Lifelovinglight
Last active June 9, 2017 02:47
Show Gist options
  • Save Lifelovinglight/baa4ce77bacfb82f71e65d0575c73c91 to your computer and use it in GitHub Desktop.
Save Lifelovinglight/baa4ce77bacfb82f71e65d0575c73c91 to your computer and use it in GitHub Desktop.
:PPP
(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