Skip to content
Browse files

not fully baked conjo

  • Loading branch information...
1 parent d8b13f7 commit c0f69ab5f43567c5a9f8932b187c51a42ed2a5da @swannodette swannodette committed Dec 4, 2013
Showing with 36 additions and 0 deletions.
  1. +36 −0 src/main/clojure/clojure/core/logic.clj
View
36 src/main/clojure/clojure/core/logic.clj
@@ -2656,6 +2656,42 @@
(cgoal (-nafc c args)))
;; =============================================================================
+;; conjo
+
+(defn -conjo
+ ([coll args]
+ (reify
+ IConstraintStep
+ (-step [this s]
+ (reify
+ clojure.lang.IFn
+ (invoke [_ s]
+ (let [coll (walk s coll)
+ args (walk s args)]
+ ((composeg
+ (== (apply conj coll (butlast args)) (last args))
+ (remcg this)) s)))
+ IRunnable
+ (-runnable? [_]
+ (and (ground-term? coll s)
+ (every? #(ground-term? % s) (butlast args))))))
+ IConstraintOp
+ (-rator [_]
+ `conjo)
+ (-rands [_]
+ (vec (concat [coll] args)))
+ IReifiableConstraint
+ (-reifyc [_ v r s]
+ `(conjo ~coll ~@(-reify s args r)))
+ IConstraintWatchedStores
+ (-watched-stores [this] #{::subst}))))
+
+(defn conjo
+ "A constraint version of conj"
+ [coll & args]
+ (cgoal (-conjo coll args)))
+
+;; =============================================================================
;; Deep Constraint
(declare treec)

0 comments on commit c0f69ab

Please sign in to comment.
Something went wrong with that request. Please try again.