Skip to content

Instantly share code, notes, and snippets.

;; differences from scheme unfold
;; even initial value is lazy
;; predicate sense reversed
;; internal state == produced value, no special mapper-fn
;; no tail-gen
(defn series
"Produces a sequence of values.
`f` is a function that given a value, returns the next value.
`continue?` is a predicate that determines whether to produce
@ghadishayban
ghadishayban / productions.clj
Last active November 20, 2021 00:06
unified generators
;;
;; Example usages at the bottom of the file
;;
(defn productions
"Returns a sequence of values by repeatedly calling `produce!` until it
returns `fin`. The sequence can be used lazily/caching or reducible/non-caching.
The arity-2 variant's `produce!` takes no arguments and returns a value
or the terminator.
(ns react-cljs.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [om.core :as om]
[om.dom :as dom :include-macros true]
[cljs.core.async :refer [>! <! chan put! sliding-buffer]]))
(enable-console-print!)
(def app-state
(atom {:counters (into [] (map (fn [n] {:id n :count 0}) (range 10)))}))
(ns react-cljs.core
(:require React))
(declare render)
(defn handle-change [e]
(render {:text (.. e -target -value)}))
(defn render [{:keys [text]}]
(React/renderComponent
(ns zmq-test.core
(:import [java.io InputStream])
(:use [org.zeromq.clojure]))
(def *ctx* (make-context 0))
(defn serialize [form]
(.getBytes (with-out-str (pr form))))
(defn deserialize [bytes]