DELAPARRA
Index
Color
NL
Category: Programming paradigms

Rule

Explained by Updated

What is Rule?

Rule: A conditional inference: HEAD :- BODY means "HEAD holds if BODY holds". grandparent(X, Z) :- parent(X, Y), parent(Y, Z). In logic programming, a rule states that something is true if certain conditions hold. In Prolog, grandparent(X, Z) :- parent(X, Y), parent(Y, Z). means X is a grandparent of Z if X is a parent of some Y who is a parent of Z.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Rule

How is Rule used in practice?

Rules let the system derive new facts from existing ones. You describe relationships once, and the engine can answer many different questions with them.

What should you keep in mind with Rule?

Business software is full of rules: discounts, permissions, shipping costs, eligibility. When those rules grow into deeply nested if statements, expressing them more declaratively helps. That can be a rules table in the database, a small rules engine, or simply a set of clearly named functions, one per rule, so each can be read and tested separately.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with R

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.