Last active
March 1, 2019 15:12
-
-
Save retupmoca/8bc324bf27b172c6911b3a9e5ed88ae4 to your computer and use it in GitHub Desktop.
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 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)))) |
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 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)) |
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 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