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 6648971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:43:08+00:00 2026-05-26T00:43:08+00:00

Anyone knows why this keeps failing? foo :- write(‘3 numbers: ‘), read(A), read(B), read(C),

  • 0

Anyone knows why this keeps failing?

foo :- write('3 numbers: '),
     read(A),
     read(B),
     read(C),
     (A > B,B > C,write(A),tab(1),write(B),tab(1),write(C));
     (A > C,C > B,write(A),tab(1),write(C),tab(1),write(B));
     (B > A,A > C,write(B),tab(1),write(A),tab(1),write(C));
     (B > C,C > A,write(B),tab(1),write(C),tab(1),write(A));
     (C > B,B > A,write(C),tab(1),write(B),tab(1),write(A));
     (C > A,A > B,write(C),tab(1),write(B),tab(1),write(A)).

Is a prolog function to print 3 input numbers in order.
I keep getting this error:

uncaught exception: error(instantiation_error,(>)/2)
  • 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-26T00:43:08+00:00Added an answer on May 26, 2026 at 12:43 am

    I think it would be better if you didn’t write everything into one clause. Not only would that make your code more readable, but you also wouldn’t make this mistake.

    The problem is that your code is parsed something like this:

    (read AND read AND read AND test) OR test OR test OR …
    

    This means that A, B and C have value only in the first test. And > requires both arguments to have a value. To fix this, you can use parentheses:

    foo :- write('3 numbers: '),
         read(A),
         read(B),
         read(C),
         ((A > B,B > C,write(A),tab(1),write(B),tab(1),write(C));
         (A > C,C > B,write(A),tab(1),write(C),tab(1),write(B));
         (B > A,A > C,write(B),tab(1),write(A),tab(1),write(C));
         (B > C,C > A,write(B),tab(1),write(C),tab(1),write(A));
         (C > B,B > A,write(C),tab(1),write(B),tab(1),write(A));
         (C > A,A > B,write(C),tab(1),write(B),tab(1),write(A))).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone know where a computer keeps what parameters it can accept through this function?
I know I am probably missing this hugely, but anyone knows why this keeps
Anyone know why this keeps returning a blank image? I found this function here
Anyone knows if this is possible? I tried it in vs 2005 and 2008
anyone knows why this does not work when I try to include a library
Is there anyone who knows this? I have been trying this for the last
I'm wondering if anyone knows how this happens? My website is down, but every
I was wondering if anyone knows an easy way to do this. I have
Dose anyone knows why I have to use -use-network=false in my Flex Builder?!?!?! This
Per this question (see comments near the bottom), I was wondering if anyone knows

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.