Re: [eclipse-clp-users] Constraints on structures

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Wed, 03 Dec 2014 17:12:53 +0000
On 03/12/14 09:10, Edgaonkar, Shrirang wrote:
> Dear clp users,
>
>    I have the following structure. I would like to have constraint on year like
> A:year > 10 and then have eclipse resolve the constraint.
>
> :-lib(ic).
>
> :- local struct( others(dvds, ratings) ).
> :- local struct( see(others, stars) ).
> :- local struct( book(author, title, year, publisher, cost, details, see) ).
>
> top(ListOfBooks):-
>    ListOfBooks = [
>       D, A, B, C
>   ],
>    A = book{see:Z, title:"tom sawyer", author:twain, cost:23.34}.
>

Some ways to do that (assuming A is a book{} structure):

     book{year:Y} = A,         % extract the year field from the book structure A
     Y #> 10.

or

     arg(year of book, A, Y),  % extract the year field from the book structure A
     Y #> 10.

or

     A[year of book] #> 10.


-- Joachim
Received on Wed Dec 03 2014 - 17:13:02 CET

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST