[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: comic-book-insult
From: |
Eric Abrahamsen |
Subject: |
Re: comic-book-insult |
Date: |
Mon, 09 Sep 2019 07:47:24 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> (defun scramble-string (str)
> "Randomize the characters of a string."
> (interactive "sscramble me: ")
> (let*((empty-str "")
> (chars (delete empty-str (split-string str empty-str)))
> (rand-chars (sort chars (lambda (_ __) (zerop (random 2)))))
> (rand-str (mapconcat 'identity rand-chars ""))
> )
> rand-str) )
You can simplify that as:
(defun scramble-string (str)
"Randomize the characters of a string."
(interactive "sscramble me: ")
(concat (sort (string-to-vector str)
(lambda (_ _) (zerop (random 2))))))