<< Back to previous view

[LOGIC-125] Using membero with a vector as an element Created: 25/Mar/13  Updated: 28/Jul/13  Resolved: 25/Mar/13

Status: Closed
Project: core.logic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Matthew O. Smith Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None


 Description   

Running this code gives an unexpected result of only one of the 2 members being present:

(defn solve1 [q]
  (symbol-macrolet   [_ (lvar)]
          (membero [_ _ 'blue-cheese 'Fortune] q) ;; 2
          (membero [:5:00 _ 'mozzarella _] q) ;; 11
          ))

(run 1 [q] (solve1 q))
=> (([:5:00 _0 mozzarella _1] . _2))

While adding an empty fresh seems to resolve the problem:

(defn solve2 [q]
  (symbol-macrolet   [_ (lvar)]
   (fresh []
          (membero [_ _ 'blue-cheese 'Fortune] q) ;; 2
          (membero [:5:00 _ 'mozzarella _] q) ;; 11
        )))

(run 1 [q] (solve2 q))
=> (([_0 _1 blue-cheese Fortune] [:5:00 _2 mozzarella _3] . _4))


 Comments   
Comment by David Nolen [ 25/Mar/13 10:52 AM ]

This is not a bug. You must always wrap a conjunction of goals in a run, fresh or an all or some other compound goal construct built from these primitives.

Comment by Matthew O. Smith [ 25/Mar/13 11:31 AM ]

Thanks, that is good to know.

Generated at Thu Sep 18 06:48:26 CDT 2014 using JIRA 4.4#649-r158309.