core.logic

Using membero with a vector as an element

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • 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))

Activity

Hide
Matthew O. Smith added a comment -

Thanks, that is good to know.

Show
Matthew O. Smith added a comment - Thanks, that is good to know.
Hide
David Nolen added a comment - - edited

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.

Show
David Nolen added a comment - - edited 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.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: