08b21b4d8af6
Make `somelist` variadic
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Sat, 02 Dec 2017 13:07:18 -0500 |
parents | 8cf0978477a8 |
children | b46ad82523a6 |
branches/tags | (none) |
files | losh.lisp |
Changes
--- a/losh.lisp Sat Dec 02 12:48:23 2017 -0500 +++ b/losh.lisp Sat Dec 02 13:07:18 2017 -0500 @@ -2204,14 +2204,19 @@ ;;;; Lists -------------------------------------------------------------------- -(defun somelist (predicate list) +(defun somelist (predicate list &rest more-lists) "Call `predicate` on successive sublists of `list`, returning the first true result. `somelist` is to `some` as `maplist` is to `mapcar`. " - (iterate (for l :on list) - (thereis (funcall predicate l)))) + (if more-lists + (iterate + (for lists :first (cons list more-lists) :then (mapcar #'cdr lists)) + (until (some #'null lists)) + (thereis (apply predicate lists))) + (iterate (for l :on list) + (thereis (funcall predicate l))))) ;;;; Debugging & Logging ------------------------------------------------------