From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: avoid narrow-to-region (was: Re: replace-regexp) Date: Sun, 9 May 2021 13:34:04 +0700 Message-ID: References: <87tunf1mz5.fsf@zoho.eu> <87v97v6mxg.fsf@gnu.org> <87wnsaz9df.fsf@zoho.eu> <877dkaytwu.fsf@zoho.eu> <87eeegx25w.fsf_-_@zoho.eu> <87fsywtp3f.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39680"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 09 08:35:36 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lfd2O-000AEf-Jt for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 09 May 2021 08:35:36 +0200 Original-Received: from localhost ([::1]:54342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfd2N-00059z-Mh for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 09 May 2021 02:35:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfd18-00059c-AX for help-gnu-emacs@gnu.org; Sun, 09 May 2021 02:34:22 -0400 Original-Received: from mail-ua1-x932.google.com ([2607:f8b0:4864:20::932]:36737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfd16-00025H-Rw for help-gnu-emacs@gnu.org; Sun, 09 May 2021 02:34:17 -0400 Original-Received: by mail-ua1-x932.google.com with SMTP id x9so4223192uao.3 for ; Sat, 08 May 2021 23:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=SCInT2/cL3s8DDoPaPLh7Suy3GZIJkodTXSquEZuFnc=; b=lH6aq0TDKMPou4mUuW9AlqBvB0osviovX/9geM/MINtJ6Bd7+mwhhL3XSw6LU9pHMs 2PlzjukSfjjoKAJpzM1i1YyT8OYFl3aEk89QXqQYcYy2+UCgt4+rMqoAEyIbq2floVE1 0JFrolLTlR9K/lHFMOi0zCBCs8z8/bJ4gVBV0xZToeE7GePb4VODruO29fBnqpcqnNFf 81636q5jE7e2+LrkheSJ4bWHD0hcGCRAfw1fpMsgyE90A1HTinKFDG9nxWot5988dGrD ilHzA8etIW+fLu5lcfliXDdJbQxb7Dd/eLfK/Bm/rGrmMA3v3DL5OT7AIP+mpOntyzH8 9PNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=SCInT2/cL3s8DDoPaPLh7Suy3GZIJkodTXSquEZuFnc=; b=BIoFY2MywpvK65Zz6IMhl+QhRkYDBIXMH6Hm5+3Y3C7JmgfVvfQWB4ue07ECiQtEzR j8qfI/oQ4+ABHR2urVtd3WyTMCwE8gdrAu8T8JsUaMySR37RZozROFpZpHOUyfAMjOBM 2b+huy6Bfj9/ciwX1ClwRuyq3MMfmkxs205TXE9y5bPljwa9sDvHOc5Z2derfP5/3bOs 5a6ehIKqyKKcI47bqaNVObPHXwkIHy5oSM7yTxgXQHsQ9xTiSSqfEBvjcjE6jt/cCA6u RDGXNu8DmNb96iiDCfbu2uEALjAGiy6LBXhi9OdT9f1sjd+A5vBU5og/KRzbMXWnKrfC Ue9g== X-Gm-Message-State: AOAM531t6Z+W5INi2vDNWYEZBHckYEGftPmbFHnWWX3upzBfJuzEEBay F/P8NrutrBm+8tGHVCZ9glyqPAtGOa3AFncNdbg= X-Google-Smtp-Source: ABdhPJzeGdCra05mI9q9EnDhhVT5aYUz+kzvbybu+vf8Z8LgwQve8ppZAR2o9XF+QhVjEAHqdDPIogf8Eauga26nJj4= X-Received: by 2002:a9f:368f:: with SMTP id p15mr15726669uap.41.1620542055754; Sat, 08 May 2021 23:34:15 -0700 (PDT) In-Reply-To: <87fsywtp3f.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::932; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x932.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129600 Archived-At: On Sun, 9 May 2021 at 13:10, Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > * Consistency: If (f a b) returns t once, it must return > > t when called again with the same arguments. [...] > > But here, we want to randomize _every time_. Every time you do a random shuffle, but not within a single shuffle. A theoretically sound (but still unnecessarily slow) sorting-based shuffle would first assign a random weight to each line, and then sort by that weight. But contrast with this: * Count the lines to be shuffled. Call it N. * Generate a random number K_1 from 1 to N. Swap line 1 with line K_1. * Generate a random number K_2 from 2 to N. Swap line 2 with line K_2. =E2=80=A6 * Generate a random number K_{N-1} from N-1 to N. Swap line N-1 with line K_{N-1}. Almost easy enough to put in Elisp, and guarantees uniform distribution (as long as individual random indexes are uniformly distributed).