Support cycle/focus-item

I oftentimes call `cycle/focus` and pass `(lambda (a) (equal a b))`. This
function should tighten up my code.
This commit is contained in:
William Carroll 2020-02-08 15:55:59 +00:00
parent 3f54dd8601
commit f145bc9eb6

View file

@ -131,6 +131,11 @@ underlying struct."
(cycle/jump i cycle) (cycle/jump i cycle)
(error "No element in cycle matches predicate")))) (error "No element in cycle matches predicate"))))
(defun cycle/focus-item (x xs)
"Focus ITEM in cycle XS.
ITEM is the first item in XS that t for `equal'."
(cycle/focus (lambda (y) (equal x y)) xs))
(defun cycle/contains? (x xs) (defun cycle/contains? (x xs)
"Return t if cycle, XS, has member X." "Return t if cycle, XS, has member X."
(->> xs (->> xs