Does it have a rule without passing a variable against the philosophy of declarative programming or prolog?

cancer():-
   pain(strong),
   mood(depressed),
   fever(mild),
   bowel(bloody),
   miscellaneous(giddy).

diagnose():-
   nl,
   cancer()->write("has cancer").

for example, a dog (X) says that X is a dog, but my cancer application just checks to see if the following conditions are true. Is there a better way to do this?

+4
source share
2 answers

In pure Prolog, a predicate without any arguments can only work with success or failure (or fail in all).

, . , , : true/0, zero , , : false/0, . , , .

, , , .

, . , , < > . , , .

, Prolog , .

, :

  • , , .
  • .

, , :

cancer(Patient):-
        patient_pain(Patient, strong),
        patient_mood(Patient, depressed),
        patient_fever(Patient, mild),
        patient_bowel(Patient, bloody),
        patient_miscellaneous(Patient, giddy).

, , , , .

, , , Prolog query ..

, , , patient_diagnosis/2, . , , .

: , , , , . , " " " ", , , .

. .

+4

cancer() , .

cancer

.

cancer.   % fact

cancer :- blah blah  %rule

, -

nl - , .

. , , , . API .

my_handler(Request) :-
      development,
      blah blah

,

, .

+3

Source: https://habr.com/ru/post/1689490/


All Articles