bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#45539: 26.3; `add-to-ordered-list': Add optional arg for :test predi


From: Drew Adams
Subject: bug#45539: 26.3; `add-to-ordered-list': Add optional arg for :test predicate for hash table
Date: Wed, 30 Dec 2020 09:55:55 -0800 (PST)

Let me know if you want a separate bug for the following.

The doc for this function does not, I think, convey what it's really about.  
And part of the reason for that, I guess, is that it hasn't (until now) allowed 
for list-element comparisons other than `eq'.

What this function is really about, I think, is this: a list with unique 
elements - no duplicates.

With your fix of this bug, "unique" will be defined by the new TEST arg 
(predicate).  Until then, "unique" is defined by `eq'.

This is important, as it means that this function is not only for adding an 
element at a given list position.  It's about having a list of unique elements, 
and being able to not only add (or remove) but also _change the position_ of an 
existing element.

That's not obvious from the current doc, but it seems to be the raison d'etre 
for this.

You have a list of 314,159 elements, and you want to change the value of the 
2,067th element?  Use this function to do that.

Think of your Netflix DVD queue.  You can add or remove elements, of course.  
But more importantly, you can move the DVD that's currently at position 147 to 
position 3.

It's vital to understanding this function that users know that the list has no 
duplicates.  Otherwise, the repositioning makes no sense.  And "no duplicates" 
depends on the meaning of "unique", i.e., the TEST-predicate optional arg or 
`eq' by default.





reply via email to

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