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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:42:32+00:00 2026-06-03T13:42:32+00:00

:-dynamic listofQuestions/2. myrule:- write(‘P = ‘), write(Percent), write(‘-‘),write(X), ( listofQuestions(Percent,X) -> true ; assert(listofQuestions(Percent,X))

  • 0
:-dynamic listofQuestions/2.
myrule:-
    write('P = '), write(Percent), write('-'),write(X),
    ( listofQuestions(Percent,X) -> true ; assert(listofQuestions(Percent,X)) ),

The code snippet might not be required to answer my question.

I want to assert to a blank ‘listofQuestions’ everytime I call my rule. This only happens if I close my prolog window and restart it.

Any suggestions?

  • 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-06-03T13:42:33+00:00Added an answer on June 3, 2026 at 1:42 pm

    abolish/1 removes all clauses of a given predicate from the database. Hence, just add a call to abolish(PredName/Arity) whenever you need to remove the information about this predicate. Beware that after abolishing the call to the dynamic predicate does not fail but reports an error.

    12 ?- f(X,Y).
    false.
    
    13 ?- assert(f(a,b)).
    true.
    
    14 ?- f(X,Y).
    X = a,
    Y = b.
    
    15 ?- abolish(f/2).
    true.
    
    16 ?- f(X,Y).
    ERROR: user://2:67:
            toplevel: Undefined procedure: f/2 (DWIM could not correct goal)
    

    In SWI-Prolog, abolish works on static procedures, unless the prolog flag iso is set to true. If you intend to remove only dynamic predicates, you should better try retractall. Observe that in this case removal does not lead to an error being reported but to a failure.

    17 ?- [user].
    :- dynamic f/2.
    |: 
    % user://3 compiled 0.00 sec, 264 bytes
    true.
    
    18 ?- f(X,Y).
    false.
    
    19 ?- assert(f(a,b)).
    true.
    
    20 ?- f(X,Y).
    X = a,
    Y = b.
    
    21 ?- retractall(f(X,Y)).
    true.
    
    22 ?- f(X,Y).
    false.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dynamic Data question: I have 2 fields of type Nullable<DateTime> on my model When
Dynamic animation using storyboards There is a question i have found that relates directly
Dynamic Linq is provided as a sample for VS2008, not as a real project
I build a dynamic breadcumb, and some parts of it are not valid urls
Dynamic queries are not dynamic enough. I have seen solutions like this but still
?-dynamic(setup/5). setup :- seeing(S), see('people.txt'), read_data, write('data read'), nl, seen, see(S). read_data :- read(A),
Eclipse Indigo has a Dynamic Web Project wizard(File->New ->Other->Web->Dynamic Web Project) I am not
Dynamic languages are on the rise and there are plenty of them: e.g. Ruby,
Dynamic allocations with new/delete are said to take place on the free-store , while
Dynamic integer will be any number from 0 to 150. i.e. - number returns

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.