A simple way is to first step through the list for the first element. If found return the new list from that point. Next search the new sublist for the second element.

- Code: Select all
`(defun verify (lst a b)`

(labels ((is-found (lst x)

(cond

((null lst) nil)

((equal x (car lst)) lst)

(t (is-found (cdr lst) x)))))

(let* ((find-a (is-found lst a))

(find-b (is-found find-a b)))

(if (and find-a find-b)

t

nil))))

(is-found) recursively parses the list and returns the list from the found location down to the end. Next you just apply it for the first atom, then check the new list for the second.

Note: You stated in the subject line "one after another" but then in the description state that the second element could be anywhere. If you need it to be directly after just recursively look for the first element and then check if the cadr is the second.

- Code: Select all
`(defun verify-next (lst a b)`

(cond

((null lst) nil)

((and (equal (car lst) a) (equal (cadr lst) b)) t)

(t (verify-next (cdr lst a b)))))