Prolog 规则反映结构

发布于 2024-09-10 03:12:27 字数 290 浏览 7 评论 0原文

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

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

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

如何实现这一目标?

谢谢。

i need to design a rules which test a loan is a car loan or not.

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

I need to test the Y and Z variable against the structure from the fact inside the rule.

How to achieve that ?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖凝香 2024-09-17 03:12:27
iscarloan(X, Y, Z) :-
  carLoan(X, minLoanAmount(MinLoan), maxTenure(MaxTenure)),
  Y >= MinLoan,
  Z =< MaxTenure.

这就是你的想法吗?

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

It that what you had in mind?

放手` 2024-09-17 03:12:27
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).
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).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文