Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

ITT Clojure stuff

Name: HMA FAN 2008-11-22 0:20

(defn bb [tag string]
  "Applies a tag to a given string, generating VALID BBCODE."
  (str "[" tag "]" string "[/" tag "]"))

;; Not included: "br", "#", "rem"
(def tags '("b" "s" "sup" "sub" "aa" "m" "code" "u" "o" "spoiler"))

(defn random-bb [str]
  "Applies a randomly chosen BBCode transformation to the given string"
  (bb (nth tags (rand-int (count tags))) str))

(defn tokenize-str [str]
  "Turns a string into a list of words. Keeps the newlines etc. but not spaces. Shitty but it works."
 (re-seq #"[\\r\\t\\n,\\S]+" str))

(defn random-bbize [odds string]
  "Applies random BBCode to every word in a text.
   Will fuck up the format somewhat, but you don't care."
  (apply str (interleave (map random-bb (tokenize-str string)) (repeat " "))))


I made a basic shit GUI with NetBeans, so it's also a demo of calls going from Java to Clojure. Dead easy. random-bbize could be made to use a BBCode Intensity Factor but I haven't been assed to it yet.

Name: Anonymous 2008-11-22 5:05

NO EXCEPTIONS

Name: Anonymous 2009-01-02 22:44

bampu pantsu

Name: Anonymous 2009-01-02 23:23

Feels good man

Name: Anonymous 2009-01-03 10:15

>>1
fialyour

Name: Anonymous 2013-01-18 23:00

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List