question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

calling `consult` several times

See original GitHub issue

Can you explain what happens when we call consult several times on the same session? Are the rules from the first call erased or not?

Let me illustrate my question by a code example:

session = pl.create()
session.consult(`p(a).`);
session.query(`p(X).`);session.answers(x=>console.log(pl.format_answer(x)), 5);
// X = a ;

Now I am creating rule q(a), and the p(a) rule is still there.:

session.consult(`q(a).`);
session.query(`p(X).`);session.answers(x=>console.log(pl.format_answer(x)), 5);
// X = a ;

But when I create the rule p(b), the rule p(a) is not there any more:

session.consult(`p(b).`);
session.query(`p(X).`);session.answers(x=>console.log(pl.format_answer(x)), 5);
// X = b ;

The question is: why when I am adding p(b) it erases p(a) but not when I am adding q(b)?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
viebelcommented, Jan 8, 2019

But now I have a different problem. The rules are now duplicated.

session = pl.create();
session.consult("p(a).");
session.consult("p(b).", {reconsult: false});
session.consult("p(b).", {reconsult: false});
session.query("p(X).");
session.answers(x=>console.log(pl.format_answer(x)), 5); // X = a ; X = b. ; X = b.

I’m not sure that what I am asking makes sense but what I’d like is to keep old rules and to add new rules only when the exact same rule doesn’t exist yet.

The context of all my questions is for the integration of Tau Prolog into Klipse as it is demonstated here.

Each code snippets is pass to a pl.consult() call. I want to allow the blog writer to spread the rules among different code snippets.

Does it make sense @jariazavalverde ?

1reaction
pmouracommented, Jan 8, 2019

In the past, Prolog systems provided both consult/1 and reconsult/1 predicates with semantics close to what you discussed and implemented here. But the distinction was lost and several systems today implement consult/1 with reconsult/1 semantics. ISO never standardized a consult predicate, unfortunately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Fine Art of Calling a Consult - BoardVitals Blog
Always match up the urgency (see above) of the consult with the time of day. This means if the consult is urgent, call...
Read more >
How to Call a Consult - REBEL EM - Emergency Medicine Blog
1. Caller is not ready · 2. No clear question · 3. No previous contact · 4. System is overloaded · 5. Known...
Read more >
A CONSULT Card and Training to Improve Resident Consults
Trainees believe that consult interactions impact patient care, but important components of the consult call are often missing. Our training and CONSULT card...
Read more >
Calling consults | Student Doctor Network
A safe rule of consults is have a quick one sentence question that you are hoping the consult will answer. If the consult...
Read more >
Calling a consult: Disrespect from specialists hurts patients
There are a few important things that must occur for a consult to be productive. The person calling the consult: Must carefully select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found