Skip to content

Instantly share code, notes, and snippets.

@retupmoca
Last active March 1, 2019 15:12
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 retupmoca/8bc324bf27b172c6911b3a9e5ed88ae4 to your computer and use it in GitHub Desktop.
Save retupmoca/8bc324bf27b172c6911b3a9e5ed88ae4 to your computer and use it in GitHub Desktop.
(defun unsolvable-p (list)
(let (island-1 in-island)
(flet ((island-fails () (if in-island
(if island-1
(clearf island-1 in-island)
t)
nil)))
(dolist (x list)
(if (null x)
(when (island-fails)
(return t))
(markf in-island))
(when (is-1 x)
(markf island-1)))
(island-fails))))
(defun unsolvable-p (list)
$(island-1 nil)
$(in-island nil)
$#(island-fails ()
(if in-island
(if island-1
(clearf island-1 in-island)
t)
nil))
(dolist (x list)
(if (null x)
(when (island-fails)
(return t))
(markf in-island))
(when (is-1 x)
(markf island-1)))
(island-fails))
(defun inline-let (stream char)
"
read-macro for '$', used for declaring locals without adding
a level of indentation.
$(name expr) ; expands to (let ((name expr)) ...)
$#(name args body) ; expands to (flet ((name args body)) ...)
$@(name args body) ; expands to (macrolet ((name args body)) ...)
$!(name expr) ; expands to (symbol-macrolet ((name expr)) ...)
"
(declare (ignore char))
(flet ((collect-rest () (iter (while (not (eql #\) (peek-char t stream))))
(for expr next (read stream))
(collect expr))))
(let ((twigil (peek-char nil stream)))
(cond
((eql #\# twigil)
(read-char stream)
`(flet (,(read stream))
,@(collect-rest)))
((eql #\@ twigil)
(read-char stream)
`(macrolet (,(read stream))
,@(collect-rest)))
((eql #\! twigil)
(read-char stream)
`(symbol-macrolet (,(read stream))
,@(collect-rest)))
(t
`(let (,(read stream))
,@(collect-rest)))))))
(defreadtable ade-syntax
(:merge :standard)
(:macro-char #\$ #'inline-let t))
(export '(ade-syntax))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment