我用或运算符定义了一个规则,但它返回多个true或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).
Run Code Online (Sandbox Code Playgroud)
实际上,我需要检查贷款类型是否符合特定贷款要求并与一般规则相结合.
换句话说,我需要像这样定义上面的规则.
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)
Run Code Online (Sandbox Code Playgroud)
它应该在命令行中返回1个true/false而不是多个语句.
每个或者规则返回1布尔值,这是我想要的后检查命令行中的规则.我需要这样(一般规则和(多重或规则)).
如何组合几个或返回1布尔值的规则?
请帮忙.
谢谢.
小智 5
只需用 包围您所有的“或”目标即可once。
例如
once(
ispersonalloan(LoanType,LoanAmount,LoanTenure);
ishouseloan(LoanType,LoanAmount,LoanTenure);
isbusinessloan(LoanType,LoanAmount,LoanTenure);
iscarloan(LoanType,LoanAmount,LoanTenure)
).
Run Code Online (Sandbox Code Playgroud)
现在,“or'ed”目标要么成功,要么失败。