Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 668999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:06:11+00:00 2026-05-14T00:06:11+00:00

I want to write a rule in prolog, which basically says If a user

  • 0

I want to write a rule in prolog, which basically says If a user X has not paid amount Y within 7 days then it will evaluate to payment_outstanding(X).

so far i have something like this:

debtpayment_unfulfilled(X) :- owes_money(X, Amountowed, Amountpaid, Days), Days > 7 ,Amountowed > Amountpaid.

owes_money(bob, 500, 0, 3).            //bob borrowed 500 on day 3

the rule works, but the problem is the Days + 7 part, for example in the system if someone borrowed on day 3 then the clause will never evaluate to true has Days will always be 3, how can i implement this? do i have to write a seperate rule?? hope you understand what im trying to say.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:06:11+00:00Added an answer on May 14, 2026 at 12:06 am

    If I’ve got you correctly, this is not possible. You should implement in your rule owes_money(bob, 500, 0, 3). exact date when bob take the money and then compare it to today’s date.

    For getting the exact date take a look at this predicate: get_time(-Time). And also for dealing with time you can use:

    convert_time(+Time, -String)
    convert_time(+Time, -Year, -Month, -Day, -Hour, -Minute, -Second, -MilliSeconds)
    

    I’m still not sure this is not a homework and I’m a little afraid to give you the solution out of the box.

    A fast solution would be to change your predicate owes_money like this:

    owes_money(bob, 500, 0, 2010, 3, 10). %2010 for the year, 3 for the month  ... 
    

    Then compare this date with the current date:

    get_time(X), convert_time(X, CurrYear, CurrMonth, CurrDay, _, _, _, _).%CurrYear will give you current year, etc ... . You don't need the hour minutes etc .. that's why are the _
    

    Now what is left is to compare CurrYear, CurrMonth and CurrDay with what you get from the owes_money predicate and see how many days have passed.

    Hope this is helpful!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write <a href=product.php?id=5> as product/5.I am not talking about user to
I want to write htaccess rewrite rule wherein if incoming url has .html or
I have the following url which i want to write a helicon RewriteRule rule
I want to write an JUnit @Rule (version 4.10) to setup some objects (an
I have a string: Range(T4).Value = Rule 13s voilation I want to write 13s
I want write a simple query which will fetch data from a table (which
I want write a little code analyzer which parses nested structures and translates into
I want to write a batch script statement where: FINDSTR has to check for
I want to write a program in Prolog that confirms if a b-tree of
I want to write a rule that redirects all URLs of a certain pattern

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.