Skip to content

Instantly share code, notes, and snippets.

@devn
Created April 1, 2010 15:17
Show Gist options
  • Save devn/351924 to your computer and use it in GitHub Desktop.
Save devn/351924 to your computer and use it in GitHub Desktop.
(defn truncate [coll t]
(let [c coll
ct (first c)
rt (second c)]
[(if (>= (count ct) t)
(apply str (take t ct) "...")
ct)
(if (>= (count rt) t)
(apply str (take t rt) "...")
rt)]))
(defn walton*
[#^String s t m?]
(let [result (walton-doc s)]
(if (>= m? 1)
(take m? (map #(truncate % t) result))
(let [random-result (nth result (rand-int (count result)))]
(truncate random-result)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment