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 t2 [ks] | |
(persistent! | |
(reduce | |
(fn [m k] | |
(assoc! m k (* k 2))) | |
(transient {}) | |
ks))) | |
(def m (t2 (range 1 1e6))) |
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
Corey-Hoffsteins-MacBook-Air:clojure choffstein$ lein new put-repo-test | |
Created new project in: /Users/choffstein/Documents/code/clojure/put-repo-test | |
Look over project.clj and start coding in put_repo_test/core.clj | |
Corey-Hoffsteins-MacBook-Air:clojure choffstein$ open put-repo-test/project.clj | |
> (defproject put-repo-test "1.0.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:dependencies [[org.clojure/clojure "1.3.0"]] | |
:disable-implicit-clean true |
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
;; enables you to define an incanter matrix (2-dimensional only) by a rule based on i j index | |
(defmacro matrix-rule [m index-rule application-fn] | |
`(incanter/matrix | |
(into [] (for [i# (range 0 (incanter/nrow ~m))] | |
(into [] (for [j# (range 0 (incanter/ncol ~m))] | |
(if (~index-rule i# j#) | |
(~application-fn i# j#) | |
(incanter/sel ~m i# j#)))))))) |