views:

25

answers:

2

Hello to all, 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.

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

It that what you had in mind?

Little Bobby Tables
I tested the rules using some queries and it shows error which point out that minLoanAmount is not a function.
peterwkc
Error message isERROR: >= /2 Arithmetic minLoanAmount is not a function
peterwkc
My bad - I fixed the matching on the 2nd line
Little Bobby Tables
A: 
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).
Mau
I tried your answers and it return false.
peterwkc
I got the answers as follow. isguarantor(X,Y) :- guarantor(X,Y), notCustomer(X).iscarloan(LoanType, Y, Z) :- carLoan(LoanType, minLoanAmount(MLA), maxTenure(MT)), Y >= MLA, Z =< MT.
peterwkc
See my edit :-)
Mau