Skip to content

Instantly share code, notes, and snippets.

View oranenj's full-sized avatar

oranenj

  • Finland
View GitHub Profile
(defn compute-metrics [[header lines]]
((fn [[ln & lns*] features experiments]
(printf "%d, %d\n" experiments (count features))
(if (not ln)
(assoc header
:experiments experiments
:features features)
(recur lns*
(time (doall (lazy-combine-sorted features (extract-features ln))))
(inc experiments))))
(let [workers nil]
(defn monitor-and-pyramid [src dest steps]
(if (empty? @workers)
(let [monitor (monitor-and-pyramid src dest)
pyramid (make-image-pyramid dest steps)]
(set! workers (list monitor pyramid))
(doseq [w workers] (.execute w)))
(do (doseq [w workers] (.cancel w true))
(set! workers nil)))))
(defn ! [ag x & args]
(send ag (@ag :receive) x args))
(defn !! [ag x & args]
(send-off ag (@ag :receive) x args))
(defn ? [ag x & args]
(let [rf (ref nil)]
(send ag (@ag :receive) x (cons rf args))
(await ag)
@rf))