Last active
March 21, 2019 14:52
-
-
Save kephas/bcc8a0315f95058fa5a8aa78ff79ea80 to your computer and use it in GitHub Desktop.
Padded binary numbers in Common Lisp
This file contains hidden or 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 read-only-chars (stream chars) | |
(with-output-to-string (result) | |
(loop while (find (peek-char nil stream) chars) | |
do (princ (read-char stream) result)))) | |
(set-dispatch-macro-character #\# #\! (lambda (stream subchar arg) | |
(parse-integer (remove #\_ (read-only-chars stream "01_")) :radix 2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment