From: Adam Porter <adam@alphapapa.net>
To: incal@dataswamp.org
Cc: emacs-devel@gnu.org
Subject: Re: Add seq-shuffle
Date: Mon, 16 Sep 2024 14:17:14 -0500 [thread overview]
Message-ID: <14bc4905-38b4-459d-8522-7cc33bbadd18@alphapapa.net> (raw)
In-Reply-To: <87msk8p4mb.fsf@dataswamp.org>
Hi Emanuel,
That's a neat and concise solution. It seems to produce a decently
random sorting, but I'd guess that it may not perform well for large
sequences. For example:
(let (comparisons)
(list :result (seq-sort (lambda (a b)
(push (cons a b) comparisons)
(zerop (random 2)))
(number-sequence 0 10))
:num-comparisons (length comparisons)))
;; (:result (6 0 9 1 5 10 8 2 7 3 4) :num-comparisons 26)
In testing that expression repeatedly, I see that the number of
comparisons varies between about 23 and 26.
Thanks for pointing it out, though. It's good to know that it exists
and in what circumstances it could be useful.
--Adam
next prev parent reply other threads:[~2024-09-16 19:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-14 7:48 Add seq-shuffle Hugo Thunnissen
2024-09-14 8:42 ` Philip Kaludercic
2024-09-16 5:08 ` Emanuel Berg
2024-09-16 19:17 ` Adam Porter [this message]
2024-09-17 4:09 ` Emanuel Berg
2024-09-17 18:37 ` Philip Kaludercic
2024-09-17 22:26 ` Adam Porter
2024-09-18 1:27 ` Emanuel Berg
2024-09-17 18:53 ` Yuri Khan
2024-09-15 1:44 ` Adam Porter
2024-09-15 6:27 ` Eli Zaretskii
2024-09-15 6:45 ` Adam Porter
2024-09-15 11:58 ` Stefan Kangas
2024-09-15 7:48 ` Hugo Thunnissen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14bc4905-38b4-459d-8522-7cc33bbadd18@alphapapa.net \
--to=adam@alphapapa.net \
--cc=emacs-devel@gnu.org \
--cc=incal@dataswamp.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).