Skip to content

Instantly share code, notes, and snippets.

@optevo
optevo / gist:aa9e64b5bd732544d05d
Created December 31, 2014 08:44
Select an execution mode for a task with one parameter (immediate, cached, delayed, agent send, agent send-off) and add priority queues.
(ns easy.scheduler
(:require [clojure.data.priority-map :refer :all]))
(def ^:dynamic *task* identity)
(def result (atom (transient {})))
(def todo (atom (priority-map)))
(deftype Now [o]
;Starting with the example of
(def rows 3)
(def cols 3)
(def cells (for [row (range rows), col (range cols)] [row col]))
(defn select-cells-by-row [row]
(filter (fn [[r c]] (= row r)) cells))
@optevo
optevo / gist:8384327
Created January 12, 2014 13:01
Change vars to fn/let and wrap
(defn grid [rows cols]
(let [cells (for [row (range rows), col (range cols)] [row col])]
(defn select-cells-by-row [row]
(filter (fn [[r c]] (= row r)) cells))
(defn print-cells-by-row [row]
(doseq [cell (select-cells-by-row row)]
(println cell)))