0.8.4-SNAPSHOT Arrow_down_16x16

waiting-stream-check

clojure.core.logic

  • (waiting-stream-check w success-cont failure-cont)
Take a waiting stream, a success continuation, and a failure continuation.
If we don't find any ready suspended streams, invoke the failure continuation.
If we find a ready suspended stream calculate the remainder of the waiting
stream. If we've reached the fixpoint just call the thunk of the suspended
stream, otherwise call mplus on the result of the thunk and the remainder
of the waiting stream. Pass this result to the success contination.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core/logic.clj:1975 top

(defn waiting-stream-check
  "Take a waiting stream, a success continuation, and a failure continuation.
   If we don't find any ready suspended streams, invoke the failure continuation. 
   If we find a ready suspended stream calculate the remainder of the waiting
   stream. If we've reached the fixpoint just call the thunk of the suspended
   stream, otherwise call mplus on the result of the thunk and the remainder
   of the waiting stream. Pass this result to the success contination."
  [w success-cont failure-cont]
  (loop [w w a []]
    (cond
     (nil? w) (failure-cont)

     (ready? (first w))
     (success-cont
       (fn []
         (let [ss (first w)
               f  (:f ss)
               w  (into a (next w))]
           (if (empty? w)
             (f)
             (mplus (f) (fn [] w))))))

     :else (recur (next w) (conj a (first w))))))
Vars in clojure.core.logic/waiting-stream-check:
Used in 0 other vars

Comments top

No comments for waiting-stream-check. Log in to add a comment.