Questions tagged [prolog-directive-dynamic]

The directive `dynamic/1` specifies that certain user-defined predicates are dynamic which are given as predicate indicators, either as in a list, in an and-sequence, or a single predicate indicator.

References:

SWI-Prolog
How to deal with the Prolog dynamic database?
Database

22 questions
1
vote
1 answer

Adapting csv reading for multiple tables

I have the following: :- use_module(library(csv)). :- dynamic mb/3. :- dynamic mb_column_keys/1. prepare_db(File) :- retractall(mb_column_keys(_)), retractall(mb(_,_,_)), forall(read_row(File, Row), store_row(Row)). store_row(Row) :- …
user27815
  • 4,767
  • 14
  • 28
1
vote
1 answer

Correct way to handle dynamic predicates in Prolog

I'm writing a Knowledge base for a robot system. The system is actually composed by two parts: the rules in the KB and a set of predicates generated by sensor readings. For example, possible rules: do(stop) :- obstacleDist(N), N<1. do(shoot(E)) :-…
Enoon
  • 421
  • 4
  • 17
1
vote
1 answer

Retracting and asserting to another file in Prolog

I'm trying to retract and assert a fact in another file. One (fruit1.pl) contains a couple of facts, and another (fruit.pl) contains a predicate start which designates which fact that another predicate insert_fruit will…
Alpine
  • 533
  • 1
  • 6
  • 18
1
vote
1 answer

Prolog getting dynamic fact values

While learning Prolog, I am writing a text-based game, this is some of it: NewHealth is Health - Damage, retract(stat(Target, health, Health)), assert(stat(Target, health, NewHealth)), I got an error about static procedures but a simple search…
DJRyan
  • 149
  • 2
  • 10
1
vote
2 answers

Can I retrieve information from another file, using Prolog?

I'm trying to write a simple translation script, but the file's getting rather... long and confusing, mostly because I've stored all the translations at the end of the file. They're in the format verb(English, Finnish). I'm wondering if there's any…
0
votes
1 answer

No permission to modify static procedure dynamic/1

dynamic( [im_at/1, door/1]). im_at(car). door(false). /* Facts*/ path(car,forward,gasstation):- door(true),write('Wellcome to Gas Station'),nl, write('You can buy a newspaper or a drink!'). path(car,forward,gasstation):- write('You need…
0
votes
1 answer

Unpredictable dynamic predicate behaviour

I have a problem that requires me to add elements to a list that are spread across various predicates. Rather than doing via argument based lists I've opted to use a dynamic list predicate. I simple example can be seen below. When I initially used…
user2211776
  • 239
  • 1
  • 2
  • 11
1
2