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

The Archive Base Latest Questions

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

I was wondering, I am aware you can use assert to add facts or

  • 0

I was wondering, I am aware you can use assert to add facts or rules or whatever if you have declared the predicate to be -:dynamic, but this only allows the changes that are made to be kept in that session only, e.g. if you close the Prolog window then the database changes are lost.

So I was wondering, is there any way of making it so that the assert and retract predicates can make permanent changes to the Prolog .pl file?

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:15:20+00:00Added an answer on May 14, 2026 at 12:15 am

    I can suggest you a very simple way of doing this.

    1 ?- assert(a(1)).
    true.
    
    2 ?- assert(a(2)).
    true.
    
    3 ?- assert(a(3)).
    true.
    
    4 ?- a(A).
    A = 1 ;
    A = 2 ;
    A = 3.
    
    5 ?- tell('a_db.txt'), listing(a), told.
    true.
    

    Then close session, reopen.

    1 ?- a(A).
    ERROR: toplevel: Undefined procedure: a/1 (DWIM could not correct goal)
    2 ?- ['a_db.txt'].
    % a_db.txt compiled 0.00 sec, 516 bytes
    true.
    
    3 ?- a(A).
    A = 1 ;
    A = 2 ;
    A = 3.
    
    4 ?- listing(a).
    :- dynamic a/1.
    
    a(1).
    a(2).
    a(3).
    
    true.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a pretty newbie question- please know I'm aware of that. I have
I have an ecommerce site and a product can have three variants. This is
In order to add events we could use this simple first solution : function
I am aware that this had been asked MANY times, but i've spent a
I'm wondering how I can accomplish the effect in figure 1. What I have
I am aware that I can use array_unique(array_merge($a,$b)); to merge two arrays and then
I'm aware of these two questions which explain why I can't have a protected/private
I am aware that this is a very basic question, but an interviewer asked
Wondering what the best / good way of doing this would be in jQuery.
Wondering if any of you can help me: I've made a signup modal that

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.