3

I am trying to use maps as my data structure and I initialize them to contain lvars to be assigned values later from other relations.

This succeeds:

(run 1 [q]
  (fresh [a b]
    (== q {:a 1 :b 2 :c b})
    (featurec q {:a b})))
-> ({:a 1, :b 2, :c 1})

But these fail:

;; Expected result -> ({:a 1 :b 2 :c _0})
(run 1 [q]
  (fresh [a b]
    (== q {:a a :b 2 :c b})
    (featurec q {:a 1})))
-> java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentMap

;; Expected result -> ({:a _0 :b 2 :c _0})
(run 1 [q]
  (fresh [a b]
    (== q {:a a :b 2 :c b})
    (featurec q {:a b})))
-> java.lang.ClassCastException: clojure.core.logic.LVar cannot be cast to clojure.lang.IPersistentMap

I am using [org.clojure/core.logic "0.8.5"]. How can I make both goals succeed?

muhuk
  • 15,777
  • 9
  • 59
  • 98

1 Answers1

1

This is due to a bug in partial-map (http://dev.clojure.org/jira/browse/LOGIC-145).

A. Webb
  • 26,227
  • 1
  • 63
  • 95
  • Thanks a lot. Seems like it's merged on 25th of Nov but there wasn't a new release since then. – muhuk Feb 03 '14 at 03:39