Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare two lists of numbers in elisp?

Tags:

emacs

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.

like image 414
quodlibetor Avatar asked Dec 27 '22 02:12

quodlibetor


2 Answers

How about this:

(require 'cl)
(every '> my-list my-other-list)
like image 91
Michael Hoffman Avatar answered Jan 02 '23 08:01

Michael Hoffman


The closest Elisp provides is probably version-list-<.

like image 42
Stefan Avatar answered Jan 02 '23 08:01

Stefan