emacs-devel
[Top][All Lists]
Advanced

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

RE: lengths and stuff


From: Tomas Hlavaty
Subject: RE: lengths and stuff
Date: Sun, 27 Dec 2020 21:52:36 +0100

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.



reply via email to

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