Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defmacro loop-do-chunked (chunk-sym list n &body body)
- (let ((elt-sym (gensym "elt"))
- (i-sym (gensym "i"))
- (n-sym (gensym "n")))
- `(loop
- with ,chunk-sym = nil
- with ,n-sym = ,n
- for ,elt-sym in ,list
- for ,i-sym from 1
- do (push ,elt-sym ,chunk-sym)
- when (zerop (mod ,i-sym ,n-sym)) do
- (progn (progn ,@body)
- (setf ,chunk-sym nil))
- finally (when ,chunk-sym
- (progn ,@body)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement