SWI-Prolog / packages-pengines

Pengines: Prolog engines
11 stars 13 forks source link

Remove SSU rule from findnsols_no_empty #57

Closed meditans closed 8 months ago

meditans commented 8 months ago

In the current version of the code, the first rule (no_chunk) never matches, because [Template] is unified in the head. While it is possible to just write the head as

findnsols_no_empty(no_chunk, Template, Goal, L) =>

and do the unification later, I think a better solution is not using SSU rules, since the two clauses can be always distinguished by their first argument (no_chunk vs count(N)).

This PR fixes this behavior and makes the recursive toplevel in pengines work as intended with chunk=false.

meditans commented 8 months ago

@JanWielemaker, here's the small tweak I was mentioning a couple days ago. Please tell me if I'm missing something!

JanWielemaker commented 8 months ago

count(N)

By duplicating count(N) you achieve a term copy. As we use this to dynamically change the chunking in Pengines next(NewChunkSize), this would no longer work. You could work around that by doing the unification in the body. I prefer the SSU rules :smile: So, delayed the unification of the list, which also makes the predicate steadfast (not that that is needed for a local helper if we know it does not matter).