Fork me on GitHub
#core-logic
<
2023-01-25
>
cddr11:01:37

Has anyone tried using core.logic to generate test-data for event-driven systems? My dream would be to define a few constraints to represent the boundaries of what events might look like and how some event in the future can be related to one in the past, and have core.logic find/generate event sequences in combinations that I wouldn’t have thought of.

cddr12:01:24

And also a more specific question about the arithmetic ns https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/arithmetic.clj I was trying to generate a pair of related events using the fragment below. It works until I try to constrain the x/y attributes such that sx/sy are greater than px/py. The code below fails because “lvar cannot be cast to number”. So how is one supposed to use the arithmetic goals? I don’t see any examples or tests that use this namespace

(run* [evs]
  (fresh [p px py]
    (fresh [s sx sy]
      (== p {:name "pass"
             :x px
             :y py})
      (== s {:name "shot"
             :x sx
             :y sy})
      (conso p [s] evs)
      (> px sx)
      (> py sy))))

cddr12:01:51

Ah figured it out. Need the fd namespace.