Created
February 3, 2018 10:38
-
-
Save porky11/2bb359f62d96822e8c25b1a3b2fc14f2 to your computer and use it in GitHub Desktop.
Bracketless lisp test
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 id (x) | |
x) | |
(defconstant o nil) | |
(defun bracketless (args &optional level) | |
(do ((result) | |
(arg (car args) (car args)) | |
(args (cdr args) (cdr args))) | |
(nil) | |
(if (and (symbolp arg) (fboundp arg)) | |
(multiple-value-bind (new-arg new-args) (bracketless args t) | |
(push (cons arg new-arg) result) | |
(setf args new-args)) | |
(progn | |
(unless (eq arg 'o) | |
(push arg result)) | |
(if level | |
(return (values (reverse result) args)) | |
(setf result (list `(progn ,@(reverse result))))))) | |
(unless args | |
(return (reverse result))))) | |
(defmacro without-brackets (&body body) | |
`(progn ,@(bracketless body))) | |
(without-brackets print + id 1 id 2 3 o print = * + id 1 2 3 9 o values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment