Hi,
I've started learning Prolog and wondering about theoritical difference from SQL language. For example they are both declarative paradigma languages, both support fact-driven knowledge database, both support question-styled data-retrieving, both support functional dependencies.
So does anybody have an idea?
Tnx in advance.
...
I searched through here as best I could and though I found some relevant questions, I don't think they covered the question at hand:
Assume a single resource and a known list of requests to schedule a task. Each request includes a start_after, start_by, expected_duration, and action.
The goal is to schedule the tasks for execution as s...
I am VERY new at Prolog I am looking for any beginner material on Prolog. I am very interested in learning the language. Where' s good place to start? Online preferably
I also am having a bit of trouble writing some code. I need to return a sentence but all I am getting is a list of atoms (i believe that's the term)
ex I get [the...
Hello hello :D :D I'm working on this this wonderful Prolog project and I'm stuck at this situation where I need to translate certain words into other words (e.g "i" into "you". "my into "your")
This is what I've done and I'm pretty sure it's kidna iffy. I enter the sentence and when It goes to convert it only changes the one word th...
Ok! last Prolog question for a loong time!!
I'm trying to pick a response that is picked at random but all I can seem to do is pick the first one out of my tables of responses (see code)
I'm sure it's done with Prologs "findall" and "random" but how?
pick_response(Sent, R) :-
response(Sent, R), !.
pick_response(_,R) :-
punt(...
I've implemented (finally) a few goals that will schedule a series of tasks according to a startBy startAfter and duration. The schedule goal however, accepts only the prescribed number of tasks. I'd like to extend the functionality of the schedule goal to accept a single list and iterate through that list while scheduling.
unfortunatel...
Hello,
I decided to study some logic programming and I stumbled across a problem.
It is programmed in SWI Prolog.
test(A, B, N):-
nonvar(B),
B = final,
true.
test(A, B, N):-
N > 2,
test(A, final, N).
test(A, B, N):-
N1 is N + 1,
test(N1, B, N1).
It is just a sample with no real use except it is driving me crazy.
The problem ...
When my friend started learning Prolog in school, I made fun of him for learning a useless language. However, he's showed me some stuff I never even knew possible; I want to know where this technique comes from.
The technique is this:
permutation(List) :-
isAMember(X, List),
deleteFirstElement(X, List, Substring),
% and so...
Hi,
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.
Thanks,
Jan
...
Hi,
I'm writing a predicate to find all possible successor states for an iteration of A* and put them in a list like [(cost, state), ...] , which stands at this at the moment:
addSuccessors(L, [], _).
addSuccessors(L, [X|T], OrigList) :- memb(OrigList, Index, X),
add((X, Index), L, List2),
...
I'm writing a predicate to add two vectors. This is what I came up with:
add( [], [], 0 ).
add( [A], 0, A ).
add( [A], [B], C ) :- C is A + B.
add( A, B, C ) :- add( B, A, C ).
add( [H1|T1], [H2|T2], WYNIK ) :- X is H1 + H2, add( T1, T2, Y ), append( [X], Y, WYNIK ).
First four lines work just fine, but I can't get the last one to wor...
I've found such an example of naive sort written in prolog and I am trying to understand it:
naive_sort(List,Sorted):-perm(List,Sorted),is_sorted(Sorted).
is_sorted([]).
is_sorted)[_]).
is_sorted([X,Y|T]):-X=<Y,is_sorted([Y|T]).
perm(List,[H|Perm]):-delete(H,List,Rest),perm(Rest,Perm).
perm([],[]).
delete(X,[X|T],T).
delete(X,[H|T],...
Hello guys, I am currently using interprolog - which is basically java with a prolog backend, allowing both java and prolog calls from each other respectively.
Now If i had say a frontend GUI coded in java swing, say a login dialog, which requested a username and password, instead of using java code to authenticate and store passwords, ...
Hello guys, I'm trying to set up an environment with interprolog and SWI prolog, interprolog needs the location of swi's "pl" but i cant find it. All i can find is swipl or plrc and neither work with interprolog. If i type pl into the terminal(this should run swi-prolog) it says
bash: pl :command not found
but if i type in
swipl
o...
Hello guys,
I have set up and installed both interprolog and swi prolog on my linux machine following the instructions here :Interprolog with SWI instructions on Linux
I have edited the unixVariables.sh to contain the path of java and swi-prolog(pl) executables on my machine and that my unixVariables.sh looks like:
# This is a typical ...
Im running prolog via poplog on unix and was wondering if there was a way to read in multiple words (such as encase it into a string).
For instance, read(X) will only allow X to be 1 term. However, if I encase the user input with "", it will return a list of character codes, is this the correct method as I can not find a way to convert i...
Hi,
I'm trying to write some predicates to solve the following task (learnprolognow.com)
Suppose we are given a knowledge base with the following facts:
tran(eins,one).
tran(zwei,two).
tran(drei,three).
tran(vier,four).
tran(fuenf,five).
tran(sechs,six).
tran(sieben,seven).
tran(acht,eight).
tran(neun,nine).
Write a predicate listtra...
Hi,
I'm trying to write a prediate that returns every third letter of a list. This is my code so far:
third([],X):-X=[].
third([_],X):-X=[].
third([_,_],X):-X=[].
third([_,_,C|T],X):- third[T,Z], X=[C|Z].
I get the "operator expected" error on the last line.
Does anyone know why?
...
Hello guys.
I'm having trouble with some of my code and I really cant trouble shoot this error.
I'm using Interprolog(Java+Prolog) see here
here is the stacktrace:
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at ...
Hello everyone. I'm having a pretty rough time trying to make use of interprolog
I have some code, trying to call a prolog command and the problem is the actual loading of my prolog database. Here is the code:
myEngine = new NativeEngine();
myEngine.consultFromPackage("userlist.p", LoginHandler.class);
boolean x = myEngine....