Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by

It is pretty common to unify a variable with a vector or list of a fixed length like {{(== q (list a b))}} and then define more goals on {{a}} and {{b}} with the intention of being able to define the * query's result format. However, if one does the same using a set one gets a StackOverflowError.

Example:

`
(run* [q]
(fresh [a b]

(== q #{a b})  ;; StackOverflowError
;;(== q [a b]) ;; works
;;(== q (list a b)) ;; works, too
(conde [(== a 1)] [(== a 2)] [(== a 3)])
(conde [(== b 1)] [(== b 2)] [(== b 3)])))

`

Basically, what I wanted to express here is that the order of {{a}} and {{b}} is not significant so that * } gives me the unique results.

The backtrace is:

`

                 logic.clj:  231  clojure.core.logic/walk*/fn
                 logic.clj:  984  clojure.core.logic/eval8917/fn
             protocols.clj:   55  clojure.core.logic.protocols/eval7398/fn/G
                 logic.clj:  229  clojure.core.logic/walk*
                 logic.clj:  233  clojure.core.logic/walk*/fn
                 logic.clj:  984  clojure.core.logic/eval8917/fn
             protocols.clj:   55  clojure.core.logic.protocols/eval7398/fn/G
                 logic.clj:  229  clojure.core.logic/walk*
                 logic.clj:  233  clojure.core.logic/walk*/fn
                 logic.clj:  984  clojure.core.logic/eval8917/fn
             protocols.clj:   55  clojure.core.logic.protocols/eval7398/fn/G

[...]
`

1 Answer

0 votes
by
...