From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: comic-book-insult Date: Mon, 09 Sep 2019 19:41:10 +0200 Message-ID: <86ftl5gyfd.fsf@zoho.eu> References: <86k1aiip6o.fsf@zoho.eu> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="198821"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 09 19:41:38 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i7NfU-000pb0-HV for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Sep 2019 19:41:36 +0200 Original-Received: from localhost ([::1]:59614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7NfT-0006FL-DY for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Sep 2019 13:41:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51277) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7NfF-0006FC-Gr for help-gnu-emacs@gnu.org; Mon, 09 Sep 2019 13:41:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7NfE-00037C-EW for help-gnu-emacs@gnu.org; Mon, 09 Sep 2019 13:41:21 -0400 Original-Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:58748 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7NfE-00035B-8A for help-gnu-emacs@gnu.org; Mon, 09 Sep 2019 13:41:20 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1i7NfA-000pFc-9r for help-gnu-emacs@gnu.org; Mon, 09 Sep 2019 19:41:16 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Cancel-Lock: sha1:bb6qTvZKXUkfCpt8oWGtNwkeX2A= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121490 Archived-At: Yuri Khan wrote: >> (rand-chars (sort chars (lambda (_ __) (zerop (random 2))))) > > If you were to pull off this kind of thing in > C or C++, that would be classified as > undefined behavior and possibly cause demons > to fly out your nose. The comparison > predicate used in sorting algorithms must be > a strict weak ordering, i.e. > > * irreflexive — (not (p x x)) for each x; > * antisymmetric — if (p x y), then (not (p y x)); > * transitive — if (p x y) and (p y z), then > (p x z); > * the equivalence induced by it must also > be transitive — if (not (or (p x y) (p y x))) > and (not (or (p y z) (p z y))), then (not (or > (p x z) (p z x))). > > A predicate that returns a random boolean on > each invocation will easily violate any or all > of the above. [...] Interesting, however does Computer Science theory of sorting apply even when the intention is to randomize the elements? > The canonical lazy coder way to random-shuffle > a collection is to first associate a random > value with each element, then sort by that: > > (concat (seq-map #'car (seq-sort-by #'cdr #'< > (seq-map (lambda (x) (cons x (random))) > (string-to-vector "@#$%&"))))) The coder can't be that lazy: seq-map: Symbol’s function definition is void: seq-sort-by -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal