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
(defmacro do-window-list | |
((varsym list &key (window-size 2) (skip 1) (ret-all t)) | |
&body body) | |
(if (not (symbolp varsym)) (error "Not an appropriate symbol name.")) | |
(let ((ivar (gensym)) | |
(lvar (gensym)) | |
(wvar (gensym)) | |
(skp (gensym)) | |
(result (gensym)) | |
(retall (gensym))) | |
`(loop with ,wvar = ,window-size | |
with ,lvar = ,list | |
with ,skp = ,skip | |
with ,retall = ,ret-all | |
for ,ivar from 0 to (- (length ,lvar) ,wvar) by ,skp | |
as ,varsym = (subseq ,lvar ,ivar (+ ,ivar ,wvar)) | |
as ,result = (progn ,@body) | |
if ,retall | |
collect ,result | |
else unless (null ,result) return ,result))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment