emacs-devel
[Top][All Lists]
Advanced

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

Re: lengths and stuff


From: Jean Louis
Subject: Re: lengths and stuff
Date: Mon, 28 Dec 2020 10:15:11 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Tomas Hlavaty <tom@logand.com> [2020-12-27 23:53]:
> On Sun 27 Dec 2020 at 10:52, Drew Adams <drew.adams@oracle.com> wrote:
> >> Using length in a predicate is yet completely different and most
> >> likely bad because to answer the predicate, traversing the whole list
> >> is wasted time and energy.
> >
> > (lambda (xs) (= (length xs) 25))  ; need to count elts
> 
> Is that a joke?
> 
> The predicates were proposed to help programers avoid writing such bad
> code.  And if somebody writes such bad code, it is almost trivial to fix
> it with search and replace:
> 
>    "(= (length" -> "(length="
>    "(< (length" -> "(length<"
>    "(> (length" -> "(length>"
>    "(/= (length" -> "(length/="
>    "(<= (length" -> "(length<="
>    "(>= (length" -> "(length>="
> 
> Also the "symmetry" (or exhaustiveness?) here is to assist in easily
> fixing bad code with minimum changes.
> 
> Nothing of course helps to those who are determined to unneccessarily
> count _all_ the elements of lists.

May I understand if that proposal is to implement it in C or in Lisp?
Does that mean when (length< list-1 10) is implemented in C it would
become faster than: (< (length list-1) 10) ?

Or is that proposal to make Lisp functions like:

(defun length< (list n)
  (when (< (length list) n)
  t))




reply via email to

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