Plaster
New
List
Login
common-lisp
default
anonymous
2018.12.17 23:35:48
(let ((list (list 1 2 3 'x 4 5 6 7 'x 8 9)) (delimiter 'x)) (loop for (head tail) = (loop for sublist on list until (eql (car sublist) delimiter) collect (car sublist) into first-part finally (return (list first-part (cdr sublist)))) do (setf list tail) collect head until (endp list)))
Raw
Annotate
Repaste
Edit
Annotations
common-lisp
default
anonymous
2018.12.17 23:41:37
(defun test-loop () (let ((orig (list 1 2 3 'x 4 5 6 7 'x 8 9)) (delimiter 'x)) (loop for list = orig then tail for (head tail) = (loop for sublist on list until (eql (car sublist) delimiter) collect (car sublist) into first-part finally (return (list first-part (cdr sublist)))) until (endp list) collect head)))
Raw
Repaste
Edit