;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/random-generic.el ;; ;; advisor: ;; add more datatypes! ;; ;; for each type the following is needed: ;; - one disassembler ;; - one call to nshuff ;; - one assembler (require 'cl-lib) (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") ;; all use the same random-sort algorithm (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) ... (provide 'random-generic)