Fork me on GitHub
#core-logic
<
2023-11-09
>
Nazral21:11:37

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 ?

hiredman21:11:29

yes, let me find it

hiredman21:11:56

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

Nazral21:11:31

ah-ah thanks !

hiredman21:11:56

ah, sorry, sublte difference in use cases

Nazral21:11:20

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

hiredman21:11:29

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

hiredman21:11:06

yeah, I think so

Nazral21:11:05

(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 !

Nazral21:11:00

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 ?

hiredman22:11:32

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

hiredman22:11:32

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

hiredman22:11:55

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

Nazral22:11:43

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