Hello,
Im trying to read a file in gprolog, but I have a small problem, it seems to read a line, then skip one, then read the next one, etc...
Heres my code :
readFichierEnt([],Fichier_Ent) :- read(end_of_file).
readFichierEnt(ExampleList,Fichier_Ent) :- read(X), write(X), readFichierEnt(ExampleList,Fichier_Ent).
If I provided train...
I can't distinguish these symbols:
= and =:=
\= and =\=
[X,Y] and [X|Y]
What’s the difference ?
...
member(K,[a,b,c,d]) if for one of ...
What's the statement for two of ...?
...
How to define a as a integer/float number ?
I want to find the results of a+b+c+d=10 where a,b,c,d is integer and >=0.
...
I'd like to know about specific problems you - the SO reader - have solved using constraint programming and what constraint logic language you used.
Questions:
What problems have you used constraint programming to solve?
What constraint logic language did you use?
I'm looking for first-hand experiences, so please do not answer unles...
Hi,
I had a quick question re. existential qualifier using setof in prolog (i.e. ^).
using SICStus it seems that (despite what a number of websites claim), S does indeed appear to be quantified in the code below (using the bog standard, mother of / child of facts, which i havent included here):
child(M,F,C) :- setof(X,(mother(S,X)),C)...
If
a+b+c=1
a^2+b^2+c^2=2
a^3+b^3+c^3=3
then
a^4+b^4+c^4=?
I've known the result is 25/6,but how to calculate it by prolog?
I tried this but failed:
[1] 5 ?- A+B+C=:=1,A**2+B**2+C**2=:=2,A**3+B**3+C**3=:=3.
ERROR: Unhandled exception: =:=/2: Arguments are not sufficiently instantiated
...
Hi all,
May be this sort of question has been asked many times( as I see the list when I move the cursor to this messagebox), But my company has a project running in Prolog and I want to clarify few things about how to go about learning it. I know Prolog is different. It should not be learnt just like any other language. Having said t...
how to read numbers from file and sorting that in (prolog programming)
...
I'm trying to match a subset of the facts I'm creating, and my testcase was working great!
x([1,2,3,4],'bleah').
x([1,2,4],'bleah2').
x([1,2],'bleah8').
x([1,3,4],'bleah3').
x([5,6,7,8],'bleah5').
x([6,7,8,9],'bleah6').
fuzzy(X,R) :- x(Z, R), subset(X,Z) .
remaining(X,Y,D,M) :- x(Z,D) , select(X,Z,N), select(Y,N,M).
pair(X,Y,R) :- x(...
I was resolving some prolog exercises when I fond myself with some difficulties resolving the following one:
Consider you have this fact base about object:
object(obj1).
object(obj2).
object(obj3).
object(obj4).
object(obj5).
material(obj1,wood).
material(obj2,wood).
material(obj3, glass).
material(obj4, glass).
material(obj5, ...
I'm taking my first AI course this semester at uni and we were asked to do a project on any AI topic that we find interesting and to impliment the code in "Prolog". One example is Implementing 4 or 5 search algorithms and comparing the effeciency in different selected special cases. I just need a topic in the same level. plz HELP!
ps. A...
I am trying to create a custom enumeration via a series of facts.
greater(X,Y) :- less (Y,X).
less(a,b).
less(b,c).
less(c,d).
This works fine, however there is significant repetition.
I'm trying to cut that down. Is there a way to use an array for a simple linear series of facts via a transformation?
transform([a,b,c,d])
result...
Hello,
I'm trying to define the inheritance-check predicate is_a/2 in Prolog, but so far all my trials failed.
The is_a(X, Y) predicate should return true whenever Y is a superclass of X. For example:
object(bare).
object(mammal).
object(animal).
object(bird).
is_a(bare, mammal).
is_a(mammal, animal).
is_a(bird, animal).
is_a(X, Y):- ...
Hi,
I am trying to display a network share path in my Prolog output code.
The path is like :
\\fileserver\path\to\file.txt (ex1)
or
\\\\fileserver\\path\\to\\file.txt (ex2)
but If I try displaying it using format :
pri(Z):-
format('Printing Zx : \"~w\"',[Z]).
the slashes get truncated to
\fileserverpathtofile.txt...
I'm trying to apply the simplified algorithm in Prolog, but I'm not a Prolog master. I need it without any mistakes, so I thought you guys might be able to help.
What is the implementation of DPLL algorithm in Prolog?
...
i'm learning YAP on my own. i have a ready made program in YAP .. and i don't know how to consult it to load it to the program menu!
the code is in C:\Users\Majd\Desktop\XXX.pl
...
I'm implementing a software by jpl provided by swi-prolog for calling prolog from java. I'm using Eclipse as IDE. I don't know how to start this example very useful for my purposes that I found on line with other prolog files.
Here the java code:
package prolog;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.ev...
I have to write program that prints a truth table of expressions.
So, I wrote the following function:
bool(true).
bool(fail).
tableBody(A,B,E) :-
bool(A),
bool(B) ,
write(A) ,
write(' '),
write(B),
write(' '),
write(E),nl, fail.
My problem is that E (wich is expression that contains A and B) is not e...
Hello all. I need to do the following: given a list of lists I need to find all possible combinations of the lists such that if some of these lists belong in such a combination, then they have no elements in common and the list created by appending the lists in the combination has a given length. Any ideas?
Thanx
...