Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Optimize map-sum so we don't OOM when there are lots of options

Using conde for domains on lots of logic vars can result in
exponential memory usage due to conde's interleaving (which is itself
caused by conde wrapping its result in -inc). This commit changes
map-sum such that it should be equivalent to the old version without
the -inc. This should be a valid change since the unification goals
should not diverge.
  • Loading branch information...
commit 5afeace2761eeb6731cf558bed354607e5401631 1 parent b19ae24
@gfredericks gfredericks authored swannodette committed
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/main/clojure/clojure/core/logic/fd.clj
8 src/main/clojure/clojure/core/logic/fd.clj
@@ -656,9 +656,11 @@
(fn loop [ls]
(if (empty? ls)
(fn [a] nil)
- (conde
- [(f (first ls))]
- [(loop (rest ls))]))))
+ (fn [a]
+ (mplus
+ ((f (first ls)) a)
+ (fn []
+ ((loop (rest ls)) a)))))))
(defn to-vals [dom]
(letfn [(to-vals* [is]
Please sign in to comment.
Something went wrong with that request. Please try again.