Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(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
You can’t perform that action at this time.