core.logic

Combining maps and finite domains in core.logic returns only one result

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Clojure 1.4.0, core.logic 0.8.0-beta2

Description

I'm trying to combine maps with finite domains with some odd results.

A simple query using finite domains correctly returns all values:

(run* [q]
	  (fresh [x]
	    (infd x (interval 1 3))
	    (== q x)))
	
	;=> (1 2 3)

But putting this result in a map returns only the first value:

(run* [q]
	  (fresh [x]
	    (infd x (interval 1 3))
	    (== q {:foo x})))
	
	;=> ({:foo 1})

FYI this works with vectors:

(run* [q]
	  (fresh [x]
	    (infd x (interval 1 3))
	    (== q [x])))
	
	;=> ([1] [2] [3])

But lcons seems to fail as well:

(run* [q]
	  (fresh [x]
	    (infd x (interval 1 3))
	    (== q (lcons x 'foo))))
	
	;=> ((1 . foo))

Activity

David Nolen made changes -
Field Original Value New Value
Status Open [ 1 ] In Progress [ 3 ]
David Nolen made changes -
Description I'm trying to combine maps with finite domains with some odd results.

A simple query using finite domains correctly returns all values:

(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q x)))

;=> (1 2 3)

But putting this result in a map returns only the first value:

(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q {:foo x})))

;=> ({:foo 1})

FYI this works with vectors:

(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q [x])))

;=> ([1] [2] [3])

But lcons seems to fail as well:

(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q (lcons x 'foo))))

;=> ((1 . foo))
I'm trying to combine maps with finite domains with some odd results.

A simple query using finite domains correctly returns all values:

{code}
(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q x)))

;=> (1 2 3)
{code}

But putting this result in a map returns only the first value:

{code}
(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q {:foo x})))

;=> ({:foo 1})
{code}

FYI this works with vectors:

{code}
(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q [x])))

;=> ([1] [2] [3])
{code}

But lcons seems to fail as well:

{code}
(run* [q]
(fresh [x]
(infd x (interval 1 3))
(== q (lcons x 'foo))))

;=> ((1 . foo))
{code}
David Nolen made changes -
Resolution Completed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: