emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add new lisp function length= with bytecode support


From: Constantin Kulikov
Subject: [PATCH] Add new lisp function length= with bytecode support
Date: Tue, 7 Mar 2017 16:52:11 +0300

Why not `length-cmp' which will -1 if less, 0 if equal, 1 if greater?

(defun length-cmp (seq n)
  (let* ((len (if seq (if (consp seq)
                          (let ((tlen 0))
                            (while (and seq (< tlen (1+ n)))
                              (incf tlen) (setq seq (cdr seq)))
                            tlen)
                        (length seq))
                0)))
    (if (< len n) -1 (if (> len n) 1 0))))

All other functions can be build on top of it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]