Skip to content

Instantly share code, notes, and snippets.

Created March 28, 2013 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5263706 to your computer and use it in GitHub Desktop.
Save anonymous/5263706 to your computer and use it in GitHub Desktop.
reducer that just hangs
(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