Created
March 28, 2013 14:47
-
-
Save anonymous/5263706 to your computer and use it in GitHub Desktop.
reducer that just hangs
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
(ns reducerstest.core | |
(:require [clojure.core.reducers :as r] | |
[clojure.tools.trace :as t] | |
[clojure.tools.trace :as tt] | |
[taoensso.timbre :as timbre :only (trace debug info warn error fatal spy)] | |
[taoensso.timbre.profiling :as profiling :only (p profile)])) | |
(defn maxvr | |
"max value reducer (for a context where 0 is the smallest possible value" | |
([] 0) | |
([x y] (timbre/info :maxvr (str x ">" y)) (if (> x y) x y))) | |
(defn map-function | |
([x] (timbre/info :start x) (Thread/sleep (* 500 (rand))) (timbre/info :end x) x)) | |
(defn testred [] | |
(let [rm (t/trace (r/map map-function (vec (range 0 100)))) | |
max (r/fold maxvr rm)] | |
(println max))) | |
;; with 100 replaced by 1000 just hangs there after the output of t/trace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment