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: Wed, 11 Sep 2019 01:43:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Adam Porter wrote:

> seq.el makes this even easier:
>
>     (seq-sort (lambda (_ _) (zerop (random 2)))
> "01234") ;;=> "01423"

Note: One has to use _ and __, otherwise the
      byte-compiler warns "Warning: repeated
      variable _ in lambda-list".

Other than that, OK:

(require 'seq)
(defun scramble-string (str)
  "Randomize the characters of a string."
  (interactive "sscramble me: ")
  (let ((rand-str (seq-sort (lambda (_ __) (zerop (random 2))) str )))
    (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]