Created
February 19, 2010 23:49
-
-
Save statianzo/309371 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ellipsize [length text] | |
(let [words (take length (split #"\W+" text))] | |
(str (join " " words ) "..."))) | |
(defn indexed [coll] (map vector (iterate inc 0) coll)) | |
(defn index-filter [pred coll] | |
(when pred | |
(for [[idx elt] (indexed coll) :when (pred elt)] idx))) | |
(defn index-of-any [pred coll] | |
(first (index-filter pred coll))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment