Skip to content

Instantly share code, notes, and snippets.

@jamii
Created December 13, 2012 23:13
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 jamii/4281009 to your computer and use it in GitHub Desktop.
Save jamii/4281009 to your computer and use it in GitHub Desktop.
(deftype PromiseSeq [p] ; p is a promise containing either nil or [val PromiseSeq]
clojure.lang.ISeq
(first [this]
(first @p))
(next [this]
(second @p))
(more [this]
(second @p))
(cons [this o]
(throw (Exception. "PromiseSeq does not implement cons")))
clojure.lang.Seqable
(seq [this]
this))
(defn pseq []
(PromiseSeq. (promise)))
clojure.core.logic.bench=> (def p (pseq))
#'clojure.core.logic.bench/p
clojure.core.logic.bench=> (seq p)
AbstractMethodError clojure.lang.RT.seqFrom (RT.java:480)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment