core-logic

Nazral 2023-11-09T21:15:37.986539Z

Hello, I see how everyg work, but is there a way to have something like someg that checks whether any goal is true in a coll ?

2023-11-09T21:20:29.049199Z

yes, let me find it

2023-11-09T21:21:56.254449Z

when you everyg is a conjunction of goals and there is some other functional constructor of disjunctions, the macro constructor for disjunctions is conde

2023-11-09T21:22:04.426239Z

ah or*

Nazral 2023-11-09T21:22:31.014689Z

ah-ah thanks !

2023-11-09T21:22:56.956569Z

ah, sorry, sublte difference in use cases

Nazral 2023-11-09T21:23:20.156119Z

so instead of (everyg f coll) I can do something like (or* (mapv f coll)) ?

2023-11-09T21:23:29.642069Z

and* and or* turn a list of goals into a goal, which is not exactly what everyg does

2023-11-09T21:24:06.462299Z

yeah, I think so

Nazral 2023-11-09T21:27:05.958589Z

(let [vars [(l/lvar) (l/lvar) (l/lvar)]]
  (l/run* [q]
    (l/== q vars)
    (l/everyg #(fd/in % (fd/domain 1 2 3 4 5 6 7)) vars)
    (l/or* (mapv #(l/== 7 %) vars))))
seems to work, thank you !

Nazral 2023-11-09T21:40:00.037459Z

ok, additional question: I want to check that at least n goals be successful in my coll, I've succeeded in doing that with project but it seems pretty slow, any better way to do so ?

2023-11-09T21:59:28.139179Z

don't

2023-11-09T22:01:32.363009Z

I think maybe a way to do it would be to take your collection of goals, generate all the n-ary permuations of them, then and* each permuation then or* all of them

2023-11-09T22:02:32.673739Z

and if that sounds like a lot, that is in fact what the search tree ends up needing to look like if you want to exhaustively search for all options, which is why the performance is going to be bad

2023-11-09T22:02:55.868739Z

which is why if you can find other way to express what you want it might be better

Nazral 2023-11-09T22:06:43.010979Z

a simplified version of the task at hand: I have a list of goals, and a sliding window over said list of goals, and I want to make sure that in each window (say of length 3), at least 2 goals are valid