i have define a rule with or operator but it return multiple true or false.
isloanaccept(Name,Guarantor,LoanType,LoanAmount,LoanTenure)
:- customer(Name,bank(_),customertype(_),
citizen(Ci),age(Age),credit(C),
income(I),property(_),bankemployee(_)),
Ci == 'malaysian',
Age >= 18,
C > 500,
I > (LoanAmount / LoanTenure) / 12,
isguarantor(Guarantor,Name),
ispersonalloan(LoanType,LoanAmount,LoanTenure);
ishouseloan(LoanType,LoanAmount,LoanTenure);
isbusinessloan(LoanType,LoanAmount,LoanTenure);
iscarloan(LoanType,LoanAmount,LoanTenure).
Actually, i need to check whether the loan type is fulfill the particular loan requirement and combine with general rule.
In other words, i need to define the rule above like this.
Ci == 'malaysian', Age >= 18,C > 500,
I > (LoanAmount / LoanTenure) / 12,
isguarantor(Guarantor,Name)
Or with (ispersonalloan(LoanType,LoanAmount,LoanTenure);
ishouseloan(LoanType,LoanAmount,LoanTenure);
isbusinessloan(LoanType,LoanAmount,LoanTenure);
iscarloan(LoanType,LoanAmount,LoanTenur)
It should return 1 true/false rather than multiple statement in the command line.
Each of the or rule return 1 boolean value which is not i want after have checked the rule in command line. I need to have like this (General Rule & (Multiple Or Rule) ).
How to combine several or rule which return 1 boolean value ?
Please help.
Thanks.
A rule in Prolog is a clause, normally with one or more variables in it. Normally, rules have a head, neck and body, as in: eats(Person, Thing) :- likes(Person, Thing), food(Thing). This says that a Person eats a Thing if the Person likes the Thing , and the Thing is food .
Just surround all your "or'ed" goals with once
.
e.g.
once(
ispersonalloan(LoanType,LoanAmount,LoanTenure);
ishouseloan(LoanType,LoanAmount,LoanTenure);
isbusinessloan(LoanType,LoanAmount,LoanTenure);
iscarloan(LoanType,LoanAmount,LoanTenure)
).
Now, the "or'ed" goals either succeed or fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With