From Robert L.@21:1/5 to All on Sat Mar 19 01:08:52 2022
From Paul Graham's "On Lisp".
(defun before (x y lst &key (test #'eql))
(and lst
(let ((first (car lst)))
(cond ((funcall test y first) nil)
((funcall test x first) lst)
(t (before x y (cdr lst) :test test))))))
If x is found in lst before y, return the tail starting with x.
Scheme:
(define (before x y lst compare)
(let ((r (member x lst
(lambda (a b) (or (compare x b) (compare y b))))))
(and r (not (compare y (car r))) r)))