Skip to content

Instantly share code, notes, and snippets.

@raymcdermott
Last active February 11, 2023 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymcdermott/973a45df59f3370124b2683030d34449 to your computer and use it in GitHub Desktop.
Save raymcdermott/973a45df59f3370124b2683030d34449 to your computer and use it in GitHub Desktop.
Dumb quote transformations
(defn joke? [quotations r1 r2]
(let [[quotation author] (rand-nth quotations)
words (string/split quotation #" ")
words-count (range (count words))
[i1 i2] (take 2 (shuffle words-count))
start (vec (take (dec i1) words))
start (conj start (rand-nth r1))
remainder (drop i1 words)
take1 (concat start remainder)
start (vec (take (dec i2) take1))
start (conj start (rand-nth r2))
remainder (drop i2 take1)
take2 (concat start remainder)
result (mapv #(->> %
(interpose " ")
(map string/lower-case)
(apply str)
string/capitalize) [words take1 take2])
attribution (->> author vec shuffle (apply str))
mangled (->> (string/split attribution #" ")
(map string/capitalize)
(interpose " ")
(apply str))]
[author result mangled]))
(def quotes
[["Some cause happiness wherever they go; others, whenever they go." "Oscar Wilde"]
["Politicians and diapers must be changed often, and for the same reason." "Mark Twain"]
["Wrong does not cease to be wrong because the majority share in it." "Leo Tolstoy"]])
(def verbs ["crush", "blast", "smash", "destroy", "ruin"])
(def nouns ["joke", "laugh", "smile", "guffaw", "chortle"])
(comment
(joke? quotes nouns verbs)
=>
["Mark Twain"
("Politicians and diapers must be changed often, and for the same reason."
"Politicians and diapers must be changed often, smile for the same reason."
"Politicians ruin diapers must be changed often, smile for the same reason.")
"Rwt Imnaka"]
(joke? quotes nouns verbs)
=>
["Leo Tolstoy"
["Wrong does not cease to be wrong because the majority share in it."
"Joke does not cease to be wrong because the majority share in it."
"Joke does not cease to be destroy because the majority share in it."]
"Ot Toolsley"]
(joke? quotes nouns verbs)
=>
["Oscar Wilde"
["Some cause happiness wherever they go; others, whenever they go."
"Some chortle happiness wherever they go; others, whenever they go."
"Some chortle happiness wherever they blast others, whenever they go."]
"Ce Waldoris"]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment