[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: same sound random sort everywhere (was: Re: avoid narrow-to-region (
From: |
Emanuel Berg |
Subject: |
Re: same sound random sort everywhere (was: Re: avoid narrow-to-region (was: Re: replace-regexp)) |
Date: |
Fri, 21 May 2021 22:47:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis wrote:
>> Here we see it implemented for strings. If the nshuff
>> algorithm is sound data type should - you guessed it - not
>> influence anything in either way to make it more or less
>> sound. See comments.
>>
>> ;;; -*- lexical-binding: t -*-
>> ;;;
>> ;;; this file:
>> ;;; http://user.it.uu.se/~embe8573/emacs-init/random-generic.el
> Not Found
?
> For 1 single loop you download 26 kilobytes... ☻
???
I use cl-loop 26 times and FYI not just loops are in it...
>> ;; add more datatypes here... (for each type, one disassembler,
>> ;; one call to nshuff, and one assembler is needed)
>
> That above I can understand somehow, but not this below, do
> you wish to expand it?
Use the source James :)
> (defun string-random (s)
> (let*((str-lst (string-to-list s))
> (lst (nshuff str-lst))
> (str-shuff (mapconcat (lambda (c) (char-to-string c)) lst "")) )
> str-shuff) )
> ;; (string-random "Elisp is my favorite E") ⇒ " ismitrEyaE lf oivpe s"
>
> (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) ...
>
> Great, now you can make Black Jack win/loose simulator.
check out upcoming virtual-vegas.el release
--
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), 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), 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, 2021/05/09
- 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 <=
Re: replace-regexp, Jean Louis, 2021/05/07