I'm trying to make something that iterates through two lists, matching the contents - though not the sequence - of the former against the latter returning true or false depending on whether it finds a match.

(defun included (list lof-l) (if (not (eq (car list) (car lof-l))) ;; If car lst isn't car lof-l then (if (not (eq lof-l 'nil)) ;; If the second list isn't empty then (included list (cdr lof-l)) ;; Go to the next symbol in second list (if (not (eq list 'nil)) ;; If you're out of symbols in the second list (included (cdr list) lof-l) ;; Go back to the start and go to the next symbol in the first list - no work! 'nil) ;; If you're out of symbols in the first list, you're finished 't)) ;; If the symbol matches the symbol in the 2nd list you're finished

The puzzle, at least the moment, is that lof-l is getting munched on up until the point that I get to the end of it, and then I want to start with the next symbol in list starting over from the beginning of lof-l. But I've already eaten lof-l, and I don't know how to get it back.

I could keep track of the original form of lof-l as a global variable, or I could pass it down as a third variable in the function declaration, but both of those feel a bit off. The former because I can't see any other use for the thing, the latter because it seems odd to make someone input something twice.

I'm wondering if there's a more elegant way to have my lists and eat them. ^^;

It sounds like you are asking for something like (maplist (lambda (x) (included x lof-l)) list) or maybe with mapl or mapcon.

Another useful pattern is to write an entry function that takes the primary arguments in a simple form and does some simple work before calling the recursive core.In your case, this could mean having (included list lof-l) call (included-helper list lof-l list).When you don't want the separate helper function, use flet.If you have multiple "internal" helper functions that call each other, use labels