Last active
September 6, 2019 01:19
-
-
Save val314159/af11388857a26595b5f7eb5d6808d6b5 to your computer and use it in GitHub Desktop.
normalize lisp syntax
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
#| -*- lisp -*- | |
exec sbcl --script $0 $* # |# | |
;;≈ç√Ωπøπøˆøˆˆ©ƒ√∂ | |
(set-dispatch-macro-character | |
#\# #\/ (lambda(stream subchar arg) | |
(declare (ignore subchar arg)) | |
(list (quote quote) (read stream t nil t)))) | |
(defun concat(&rest r) (apply #'concatenate #/string r)) | |
(import #/(sb-impl::quasiquote sb-impl::unquote-splice | |
sb-impl::unquote-nsplice sb-impl::unquote)) | |
(set-dispatch-macro-character | |
#\# #\` (lambda(stream subchar arg) | |
(declare (ignore subchar arg)) | |
(list #/quasiquote (read stream t nil t)))) | |
(set-dispatch-macro-character | |
#\# #\, (lambda(s subchar arg) | |
(declare (ignore subchar arg)) | |
(case (peek-char nil s) | |
(#\@ (read-char s) (unquote-splice (read s t nil t))) | |
(#\. (read-char s) (unquote-nsplice (read s t nil t))) | |
(t (unquote (read s t nil t)))))) | |
(print (unquote 100)) | |
(print (unquote-splice 100)) | |
(print (unquote-nsplice 100)) | |
(print (quasiquote (quasiquote 100))) | |
(print '`,(1 2)) | |
(print '`#,(1 2)) | |
(terpri) | |
(eval `(format ,@(list t "qwert~d~%" 9991))) | |
(eval `(format ,@(list t "qwert~d~%" 9992))) | |
(eval `(format ,@(list t "qwert~d~%" 9993))) | |
(print ' `( ,format ,.(list t) ,@(list t "qwert~d ~s~%" 9994 '|q|w))) | |
(print '#`(#,format #,.(list t) #,@(list t "qwert~d ~s~%" 9994 '\qw))) | |
(print '#`(#,format #,.(list t) #,@(list t "qwert~d ~s~%" 9994 #/ \qw))) | |
(print #/#`(#,format #,.(list t) #,@(list t "qwert~d ~s~%" 9994 #/|q|w))) | |
(print #/(\/\/\/w\/w\hw)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment