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
| #!/bin/sh | |
| clj_base="${HOME}/code/clojure"; | |
| java -cp .:${clj_base}/lib/jline-0.9.94.jar:${clj_base}/clojure/target/clojure-1.5.0-master-SNAPSHOT.jar:${clj_base}/criterium-0.2.2-SNAPSHOT-standalone.jar:${clj_base}/clojurescript jline.ConsoleRunner clojure.main "$@" |
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
| (def sum-of-pos-elements (memoize (fn [xs] (apply + (filter #(>= % 0) xs))))) | |
| (def sum-of-neg-elements (memoize (fn [xs] (apply + (filter #(< % 0) xs))))) | |
| (defn subset-sum | |
| "Returns the indexes of elements in xs whose sum is s" | |
| ([xs s] | |
| (subset-sum xs (dec (count xs)) s)) | |
| ([xs i s] | |
| "Returns the indexes of elements x0...xi (in xs) whose sum is s" | |
| (let [sol (subset-sum xs i s [])] |
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
| repl-port |
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
| # encoding: utf-8 | |
| class Greeter | |
| def self.call(language) | |
| new(language) | |
| end | |
| def initialize(language) | |
| @language = language | |
| end |
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
| # 1.9.3-p194-perf - GC tweaks | |
| ✓ ~/code/sspinc/cartman » time bundle exec rake environment | |
| bundle exec rake environment 5.16s user 1.60s system 95% cpu 7.067 total | |
| ✓ ~/code/sspinc/cartman » time bundle exec rake environment | |
| bundle exec rake environment 5.23s user 1.57s system 95% cpu 7.113 total | |
| # 1.9.3-p194-perf - No GC tweaks | |
| ✓ ~/code/sspinc/cartman » time bundle exec rake environment | |
| bundle exec rake environment 6.60s user 1.44s system 98% cpu 8.157 total | |
| » time bundle exec rake environment |
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
| (ns group-by-reducers.core | |
| (:require [clojure.core.reducers :as r :only [fold reduce map]]) | |
| (:require [criterium.core :as c])) | |
| (defn group-by-naive [f coll] | |
| (reduce | |
| (fn [groups a] | |
| (assoc groups (f a) (conj (get groups a []) a))) | |
| {} | |
| coll)) |
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
| (ns benchmark-assoc.core | |
| (:require [criterium.core :as crit])) | |
| (defn no-assoc [items] | |
| (apply hash-map (vec (flatten items)))) | |
| (defn assoc-all [items] | |
| (apply assoc {} (vec (flatten items)))) | |
| (defn assoc-each-one [items] |
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
| becameInvalid: -> | |
| @get('transaction').remove(this) | |
| transaction = App.store.transaction() | |
| transaction.add(this) # => Uncaught Error: assertion failed: Once a record has changed, you cannot move it into a different transaction |