prolog-toplevel Questions
2
I'm just learning PROLOG and I'm having a difficult time understanding why the queries that I'm performing result in an ending of 'yes/no'. Here's my KB:
male(albert).
male(bob).
male(bill).
male(...
Debus asked 14/4, 2018 at 18:7
5
Solved
I'm using SWI-Prolog and I'm trying to print a list but if the list has more than 9 items - it look like that -
[1, 15, 8, 22, 5, 19, 12, 25, 3|...]
is there a way to show the whole list?
Inchoation asked 22/11, 2011 at 18:23
2
Solved
I'm beginner in SWI-Prolog (but have some experience in Borland Prolog), and I've faced with a strange behavior for the following test code:
test(10).
test(1).
It is expected for query ?-test(A)...
Lithic asked 4/6, 2017 at 13:10
2
I started to learn Prolog following the book Programming in Prolog: Using the ISO Standard. At page 7 of the intro to the language they made the assertion : "In Prolog the answer no is used to mean...
Perfusion asked 1/7, 2015 at 14:23
3
Solved
Simple example:
?- between(1,10,X).
X = 1 ;
X = 2 ;
X = 3 ;
X = 4 ;
X = 5 ;
X = 6 ;
X = 7 ;
X = 8 ;
X = 9 ;
X = 10.
When this is done using SWI-Prolog using the REPL to see the next answer the s...
Rake asked 17/1, 2019 at 22:40
3
Solved
I have a List with Integers and anonymous variables and I try to find the index of a special values. Problem is as soon I'm using nth1/3 to find the indices Prolog assigns values to the anonymous v...
Lamellicorn asked 15/5, 2017 at 17:25
5
Solved
I'm trying to convert a string to a list of ascii-codes like so:
7 ?- string_to_list("I'm a big blue banana in space!", C).
C = [73, 39, 109, 32, 97, 32, 98, 105, 103|...].
8 ?-
This doesn't g...
Likelihood asked 2/10, 2015 at 15:22
3
Solved
Imagine that I have the following knowledge base which gives for each person his first name and his age.
person(mary, 39).
person(john, 24).
person(sandy, 17).
Now, I want to retrieve all the pe...
Scrubland asked 20/1, 2016 at 5:58
1
I'm new to Prolog. I'm just trying simple examples to learn. I have this .pl file with these lines:
parent(pam,bob).
parent(tom,bob).
parent(tom,lio).
parent(bob,ann).
parent(bob,pat).
parent(pat,...
Verbosity asked 25/12, 2015 at 13:24
4
Solved
How can I make SWI-Prolog interpreter to automatically do a semicolon?
I have a lot of results (about 300) due to backtracking and I don't want to push semicolon for all of them.
I do NOT want a l...
Flexuous asked 23/1, 2014 at 16:3
3
Solved
I am trying to get a feel for Prolog programming by going through Ulle Endriss' lecture notes. When my solution to an exercise does not behave as expected, I find it difficult to give a good explan...
Jesselyn asked 31/7, 2012 at 7:15
1
Solved
I am using SWI-PROLOG version 6.6.6
I want to print all the attributes of a particular predicate type.
I have a predicate called law with arity 2.
Some of the facts are
law(borrow,'To borrow Mo...
Counterword asked 27/11, 2014 at 18:52
1
Many predicates essentially use some form of transitive closure, only to discover that termination has to be addressed too. Why not solve this once and forever with closure0/3:
:- meta_predicate(cl...
Judijudicable asked 15/11, 2014 at 13:4
1
Solved
I would like to write a small text-based adventure game using Prolog (this might be a dumb idea but I am not here to discuss that).
The only problem is that I can't manage to print text on screen ...
Negotiable asked 23/6, 2014 at 14:3
2
Solved
I'm new to prolog, and am experimenting with how to get it to stop querying after it finds one answer. I'm using this code:
member1(L,[L|_]).
member1(L,[_|RS]) :- member1(L,RS),!.
The result i...
Nowadays asked 24/11, 2013 at 20:7
3
Solved
I have a standard procedure for determining membership of a list:
member(X, [X|_]).
member(X, [_|T]) :- member(X, T).
What I don't understand is why when I pose the following query:
?- member(...
Decapolis asked 30/1, 2013 at 0:52
1
Solved
Here is what I have understood about Prolog variables.
A single underscore stands for anonymous variable, which is like a new variable each time it occurs.
A variable name starting with undersco...
Poler asked 9/1, 2013 at 15:18
3
Solved
I come up against this all the time, and I'm never sure which way to attack it. Below are two methods for processing some season facts.
What I'm trying to work out is whether to use method 1 or 2, ...
Jarlathus asked 16/3, 2012 at 21:17
2
Solved
I am reading http://cs.union.edu/~striegnk/learn-prolog-now/html/node3.html#subsec.l1.kb1,
but I am having trouble running the following predicate:
SICStus 4.0.1 (x86-win32-nt-4): Tue May 15 21:17...
Vitia asked 6/9, 2011 at 18:44
2
Solved
I'm using SWI-Prolog on Windows and am getting the following error:
14 ?- parent(X, Y) :- child(Y, X).
ERROR: toplevel: Undefined procedure: (:-)/2 (DWIM could not correct)
I'm not entirely sure...
Medellin asked 23/3, 2011 at 10:56
1
Solved
I made a little code for creating a matrix of coordinates (like a chessboard), it's the following:
createMatrix(N,M,R) :- creaMatriu(N,M,A), reversed(R,A).
creaMatriu(N,0,[T]) :- creafila(N,0,T),!...
Abutting asked 11/2, 2011 at 1:36
2
My SWI-Prolog knowledge base contains the following two facts:
f(a,b).
f(a,c).
Now if I pose the query
?- f(a,c).
true.
But
?- f(a,b).
true ;
false.
Why is f(a,b) both true and false? Thi...
Polytypic asked 24/7, 2010 at 0:2
2
Solved
I want to load this simple something into my Editor:
Write:-repeat,write("hi"),nl,fail.
So that it prints "hi".
What should I do?
I'm currently trying to do File->New
and Saving a file nam...
Lasandralasater asked 31/3, 2010 at 20:29
1
what are the two stars in a list?
[53, 5, 1, 53, 97, 115, 53, 50, 52, 121, 55, 56, 55, 97, 4, 1, 98, **]
I tried searching but no success.
Blowzed asked 1/2, 2010 at 10:12
1
© 2022 - 2024 — McMap. All rights reserved.