Questions tagged [prolog-toplevel]

The "toplevel" or "top level loop" is Prolog's REPL.

The toplevel or top level loop is Prolog's REPL.

The toplevel differs from the read-eval-print loop in several ways:

Evaluation is performed incrementally. Typically, evaluation is only performed up to determining one answer, requiring user interaction to compute the next answer.

Printing an answer includes printing answer substitutions but may also include residual constraints.

155 questions
1
vote
0 answers

Why does emacs inferior eclipse backtrack only two times?

example: [eclipse 6]: X=1;X=2;X=3. X = 1 Yes (0.00s cpu, solution 1, maybe more) ? ; <-- this ; results in the end of the query X = 2 Yes (0.00s cpu, solution 2, maybe more) ? (no chance to enter anything before the following prompt…
1
vote
1 answer

How to automate semicolon in Prolog

I am learning about Prolog in class and was shown a way to automatically press the semicolon key until there are no more solutions. I have tried searching on Google but I get examples using findall which is not what was shown. Are there any other…
Rowen McDaniel
  • 169
  • 1
  • 2
  • 11
1
vote
1 answer

Moving to previous query in XSB or Ciao (Prolog)

While using swi-prolog, one can recall previous query using the UP arrow key (at the terminal). How can this be achieved in XSB or Ciao prolog systems?
Shahzad
  • 1,999
  • 6
  • 35
  • 44
1
vote
2 answers

Prolog not giving correct answer

I am learning Prolog. I wrote some simple facts. But it seems that Prolog is not giving me right answers. Please help me understand what I am doing wrong here. facts - weather.pl weather(pheonix,summer,hot). weather(pheonix,winter,warm). …
lonewolf
  • 69
  • 9
1
vote
1 answer

How do you get only one output from a swi-prolog query?

How do I get only one output from a SWI-Prolog query? I have tried using cut (!) but it does not seem to work. For example: I already filled my knowledge base up with statements and I wanted to find any one name who is both female and is the mother…
user3369494
  • 123
  • 11
1
vote
2 answers

search in a split a sentence in prolog

I have a list L created as: atomic_list_concat(L,' ', 'This is a string'). L = ['This',is,a,string] Now I want to search an atom in L using member function. I tried : ?- member(' is',L). L = [' is'|_G268] . ?- member( is,L). L = [is|_G268]…
na899
  • 163
  • 1
  • 2
  • 9
1
vote
1 answer

how to get user input prolog and store it

I'm trying to have the user input their birthday so I can tell them their zodiac sign. However, I'm having trouble getting their actual birthday and month. Could someone please help me? I've tried separating the reads into different functors, but I…
mylasthope
  • 89
  • 7
1
vote
2 answers

Prolog - How do I catch an error of incorrect arity?

Not sure if the question is worded correctly or not, my apologies. Basically what I want to do is create some kind of error handling in Prolog. For example: fruit(apple, pear). Now if the user were to query: ?- fruit(X). How would I inform the…
1
vote
1 answer

Prolog Variable

I have a small problem when we are talking about anonymous variables. For example when we make this: ?- [_,2]=[X|Y]. Y=[2]. but my question is about the variable X. Does it have the '_'?
Miguel
  • 89
  • 2
  • 9
1
vote
3 answers

Commutativity of disjunction in Prolog

I've just started learning Prolog and I encountered a problem that I don't understand. When I ask: ?- fail; true. Prolog answers: true Which is something I expected. But, if I ask: ?- true; fail. Prolog answers: true ; false. ..and I don't…
1
vote
1 answer

How to use variables in Prolog query shell?

I know that I can use variables in Prolog shell (something like using '$' character, I think...but I don't remember...) If I execute the following query it seems to work fine: ?- leggiFile('dataggare.txt', ListaTesto), tokenizzaLista(ListaTesto,…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
1
vote
1 answer

Prolog rule - False?

I have facts: /**--(course,time,location)--*/ ctl('course1', 'time1','location1'). ctl('course2', 'time1','location2'). ctl('course3',…
Layla
  • 133
  • 3
  • 12
0
votes
1 answer

Prolog Output Doesn't Put "."

I have a prolog program which includes some predicates, when i query one of the predicates it displays the true output, but it doesn't put the "." at the end and go to the next query. ChatGPT cannot even understand the problem and i cannot think of…
0
votes
1 answer

Prolog : Never Ending Process

I am trying to use get_coeff_value() but the process never end. get_coeff_value(Val,[],[]). get_coeff_value(Val, [X|T],Coeff_List):- get_coeff_value(Val,T,Coeff_List1), get_val(Val,[X], Coeff), insert_end(Coeff_List1, Coeff,…
cece
  • 3
  • 3
0
votes
1 answer

How to assert multiple facts or rules in one assert/1 statement?

If I'm at the repl I can do ?- assert(foo(a)),assert(foo(b)),assert(foo(c)). and that works, but not ?- assert((bar(a),bar(b),bar(c))). or similar. Is there a way to only need to type "assert" once and pass in multiple facts? Same question for…