emacs-devel
[Top][All Lists]
Advanced

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

Re: Add seq-random-elt


From: Clément Pit--Claudel
Subject: Re: Add seq-random-elt
Date: Sat, 22 Oct 2016 10:53:06 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

On 2016-10-21 17:30, Stefan Monnier wrote:
>>> Hmm... do we really need that?  What's the benefit?
>> I think it's convenient.  Accessing random elements of sequences is not
>> uncommon.
> 
> Right, but
> 
>     (seq-elt L (random (seq-length L)))
> 
> it pretty convenient to write and pretty clear as well, so the benefit
> seems slim.

Indeed, but it's arguably wrong: if L is nil, random will ignore limit and 
possibly return a negative number.  seq-elt is unspecified for negative indices 
AFAICT (though it seems to return nil ATM).
So maybe we could/should have a seq-random-element, and it should check for 
nil.  If it did, then it would be a useful addition, I think.

Cheers,
Clément.



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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