Available via clojars
Current stable version: [bagotricks "1.5.5"]
A collection of miscellaneous useful Clojure functions pulled from a various different sources.
;; Highlights;
(to-long "5") ;; Coerces value provided to a long.
(->> (range 400)
(clojure.core.reducers/map inc)
fold-into-vec) ;; Fold the results of a reducer into a vector.
(->> (range 400)
(clojure.core.reducers/map vector)
fold-into-lazy-seq
dump-recs-to-file) ;; Fold the results of a reducer into a lazy sequence, and write to file (order not maintained).
(read-lines filename) ;; returns a vector where each element is a line in the file.
(re-get #"a (b) c" "a b c") ;; returns just ("b")
(split-tsv "a\tb\t\td") ;; returns ["a" "b" nil "d"]
(thread (println "this is executing in another thread!")) ;; Simply execute code in another thread (good for side effects).
;; etc.
Bagotricks artifacts are released to Clojars.
If you are using Maven, add the following repository definition to your pom.xml
:
<repository>
<id>clojars</id>
<url>http://clojars.org/repo</url>
</repository>
With Leiningen:
[bagotricks "1.5.5"]
With Maven:
<dependency>
<groupId>bagotricks</groupId>
<artifactId>bagotricks</artifactId>
<version>1.5.5</version>
</dependency>
MIT http://opensource.org/licenses/MIT
I'd also like to thank my employer Gracenote, for allowing me to release this.
NOTE: Relevant bits of bagotricks.clj are pulled from a number of sources, and credit goes to the original author. Details associated with each particular function.
Copyright (C) 2012-2013 Alan Busby