diff --git a/utils.lisp b/utils.lisp index 6813618..e3a9a74 100644 --- a/utils.lisp +++ b/utils.lisp @@ -411,6 +411,19 @@ (defun val (v) v) +(defun groupn (n list) + (let ((last nil) + (ret nil)) + (loop for x in list + for y from 0 below (length list) + do (if (= 0 (mod y n)) + (push x last) + (progn + (push x last) + (setf ret (cons (reverse last) ret)) + (setf last nil)))) + (reverse ret))) + (defun sexpr-reader (stream char &key (func 'val)) "Read next token only if S expression, else return as is" (if (char= (peek-char t stream t nil t) #\()