help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comic-book-insult


From: Emanuel Berg
Subject: Re: comic-book-insult
Date: Mon, 09 Sep 2019 05:56:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Eric Abrahamsen wrote:

> 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))))))

(defun scramble-string (str)
  "Randomize the characters of a string."
  (interactive "sscramble me: ")
  (let ((rand-str (concat
                   (sort (string-to-vector str)
                         (lambda (_ __) (zerop (random 2))) ))))
    (if (called-interactively-p 'any)
        (message rand-str)
      rand-str) ))

(defun comic-book-insult ()
  (interactive)
  (insert (concat (scramble-string "@#$%&") "!") ))

;; (comic-book-insult) ; @#$%&!
;; (comic-book-insult) ; $&#@%!

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]