[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: comic-book-insult
From: |
Marcin Borkowski |
Subject: |
Re: comic-book-insult |
Date: |
Sun, 08 Sep 2019 22:16:16 +0200 |
User-agent: |
mu4e 1.1.0; emacs 27.0.50 |
On 2019-09-08, at 21:05, Emanuel Berg via Users list for the GNU Emacs text
editor <help-gnu-emacs@gnu.org> wrote:
> (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) )
Nice, but a bit wrong. If you try it as an interactive function, it
won't display the result - only return it, but this is of no use with M-x.
> (defun comic-book-insult ()
> (interactive)
> (insert (concat (scramble-string "@#$%&") "!") ))
>
> ;; (comic-book-insult) ; %@&$#!
> ;; (comic-book-insult) ; $%#@&!
And this is rather cute, thanks for sharing!
Best,
--
Marcin Borkowski
http://mbork.pl