Created
April 1, 2010 15:59
-
-
Save devn/351984 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 truncate | |
| "A one off truncation function which takes a coll in the form of \"[:a, :b]\". Provided a [t]runcation length (in characters), it will truncate :a or :b and supply a new \"[\":a...\", \":b...\"]\"." | |
| [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)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment