[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: avoid narrow-to-region (was: Re: replace-regexp)
From: |
Emanuel Berg |
Subject: |
Re: avoid narrow-to-region (was: Re: replace-regexp) |
Date: |
Sun, 09 May 2021 17:13:28 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Let's do it like this, if we can get the algorithm to work
> on an arbitrary list, then all data-type issues can be
> solved easily, by adding two functions, one disassembly
> function that splits the data into a list, and one assembly
> function that puts it back together, after the algorithm has
> randomized it!
>
> So for example if the data is the string "data":
>
> 1. "data" -> '("d" "a" "t" "a")
> 2. run the algorithm, get e.g '("a" "d" "t" "a")
> 3. '("a" "d" "t" "a") -> "adta"
>
> Because Lisp is already based on the universal data
> structure which can express all human knowledge, isn't it
> possible that there is already a Lisp list randomizer that
> fulfills even Yuri's most uncompromising demands?
What about this?
;; https://stackoverflow.com/a/49505968
(require 'cl-lib)
(defun nshuff (sq)
(cl-loop
for i from (length sq) downto 2
do (cl-rotatef (elt sq (cl-random i))
(elt sq (1- i)) ))
sq)
;; (nshuff '(a b c)) ; (b c a) (a b c) (b c a) ...
Shufflepuck Café!
--
underground experts united
https://dataswamp.org/~incal
- Re: avoid narrow-to-region (was: Re: replace-regexp), (continued)
- Re: avoid narrow-to-region (was: Re: replace-regexp), Yuri Khan, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Yuri Khan, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp),
Emanuel Berg <=
- same sound random sort everywhere (was: Re: avoid narrow-to-region (was: Re: replace-regexp)), Emanuel Berg, 2021/05/21
- Re: same sound random sort everywhere (was: Re: avoid narrow-to-region (was: Re: replace-regexp)), Jean Louis, 2021/05/21
- Re: same sound random sort everywhere (was: Re: avoid narrow-to-region (was: Re: replace-regexp)), Emanuel Berg, 2021/05/21
Re: replace-regexp, Jean Louis, 2021/05/07