emacselisp

Compare two lists of numbers in elisp?


So, I can do this (using cl):

(loop for x in my-list
      for y in my-other-list
      if (> x y) return t
      if (< x y) return nil)

But I really feel like this should be as easy as (list> my-list my-other-list) But I can find absolutely no evidence that this function exists by any name. In fact, I can't even find any general documentation for comparing lists at all. This makes me feel like I must be missing something.

Do I have do define (list>) myself, or have I missed great swaths of documentation in my haste and confusion?

And if I have to define it myself, can you do a better job? I'm not really an elisp hacker.


Solution

  • The below provides a coordinate-wise comparison, but the question describes a lexicographic comparison.

    (require 'cl)
    (every '> my-list my-other-list)