Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Append th element of lists that match predicate to the end of the collection list (mutated);
- ;; Return the appended collection
- (defun collect-if (predicate list &optional collection)
- (loop for x in list
- when (funcall predicate x)
- do (if (null collection)
- (setf collection (list x))
- (nconc collection (list x)))
- finally (return collection)))
- (defun collect-if (predicate list &optional collection)
- (loop with coll = (cons nil collection)
- for x in list
- when (funcall predicate x)
- do (nconc coll (list x))
- finally (return (cdr coll))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement