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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:40:23+00:00 2026-05-29T19:40:23+00:00

I have the following prolog code: equiAngularTriangle(T) :- equiLateralTriangle(T). equiLateralTriangle(T) :- equiAngularTriangle(T). Is there

  • 0

I have the following prolog code:

equiAngularTriangle(T) :-
    equiLateralTriangle(T).

equiLateralTriangle(T) :-
    equiAngularTriangle(T).

Is there a way to keep the interpreter from asking the same question twice? For instance, if I ask equiAngularTriangle(t), then it’s going to ask equiLateralTriangle(t), then ask equiLateralTriangle(t), but it should know not to pursue that last one again, because the same question is on the “query stack”.

Is there an option or some special syntax that lets Prolog behave the way I want it to?

  • 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-29T19:40:26+00:00Added an answer on May 29, 2026 at 7:40 pm

    If the prolog implementation supports tabling or you are using XSB then you could use it and get the desired behaviour.

    You could also add a state argument:

    %State = [Checked_for_equiAngular, Checked_for_equiLateral]
    
    equiAngularTriangle(T, [_,false]) :-
        equiLateralTriangle(T, [true,true]).
    
    equiLateralTriangle(T, [false,_]) :-
        equiAngularTriangle(T, [true,true]).
    

    of course you will need to modify the rest of the clauses.

    The last (and best imo) option is to rewrite your predicates. I guess that your code will be similar to this example:

    ang(T):-
      foo(T).
    ang(T):-
      lat(T).
    
    lat(T):-
      bar(T).
    lat(T):-
      ang(T).
    

    so you could simply write:

    ang(T):-
      foo(T).
    ang(T):-
      bar(T).
    
    lat(T):-
      ang(T).
    

    normally you will use some wrapper predicates if instead of foo(T) you had foo1(T),foo2(T) etc

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

Sidebar

Related Questions

I'm trying to implement an increment in prolog, and have written the following code:
I have the following prolog code: predicates like(string) clauses like(apple). like(girl). q :- like(A),write(A).
I have the following Prolog code in my program: conn([oxford_circus, baker_street], 4). conn([baker_street, kings_cross],
I have the following snippet of prolog code: num(0). num(X) :- num(X1), X is
I need a way of doing the following in Prolog. I want to have
I have written the following code in SWI-Prolog: :- dynamic state_a/1 . :- dynamic
How can I count nested list elements in Prolog? I have the following predicates
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig
I have following question on adobe omniture How we can register an iPhone app

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.