DELAPARRA
Index
Color
NL
Category: Programming paradigms

Query / Goal

Explained by Updated

What is Query / Goal?

Query / Goal: A question posed to the engine, e.g. ?- grandparent(alice, W). The engine searches for a W that satisfies the rules. In logic programming, a query or goal is a question you ask the system. In Prolog, ?- grandparent(alice, W). asks: for which W is Alice a grandparent? The engine searches through its facts and rules, trying combinations and backtracking when one fails, until it finds values that make the goal true. It can return one answer or all of them.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Query / Goal

What should you keep in mind with Query / Goal?

The nice part is that the same rules answer different questions. The rule defining grandparents also answers "who are Bob's grandparents?" without writing new code. SQL works in a similar declarative spirit: you describe the result, and the database finds it. Thinking in goals rather than steps is useful whenever a problem is mostly about relationships and rules.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with Q

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.