Prolog规则反映结构

时间:2010-07-19 08:11:19

标签: prolog structure rule

我需要设计一个规则来测试贷款是否是汽车贷款。

carLoan(flexiCar,minLoanAmount(20000),maxTenure(12) ).
iscarloan(X, Y, Z) :- carLoan(X, Y >= minLoanAmount(20000), Z =<(maxTenure(12)) ).
iscarloan(X, 25000, 10).

我需要根据规则内部的事实测试结构的Y和Z变量。

如何实现?

感谢。

2 个答案:

答案 0 :(得分:1)

iscarloan(X, Y, Z) :-
  carLoan(X, minLoanAmount(MinLoan), maxTenure(MaxTenure)),
  Y >= MinLoan,
  Z =< MaxTenure.

你记得的是什么?

答案 1 :(得分:0)

carLoan(flexiCar, minLoanAmount(20000), maxTenure(12)).

iscarloan(X, Y, Z) :-
    Y = minLoanAmount(MLA),
    Z = maxTenure(MT),
    MLAN is MLA,
    MTN is MT,
    MLAN >= 20000,
    MTN =< 12.

iscarloan(X, 25000, 10).