Skip to content

Instantly share code, notes, and snippets.

@porky11
Created February 3, 2018 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porky11/2bb359f62d96822e8c25b1a3b2fc14f2 to your computer and use it in GitHub Desktop.
Save porky11/2bb359f62d96822e8c25b1a3b2fc14f2 to your computer and use it in GitHub Desktop.
Bracketless lisp test
(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