Iterative search using Prolog solve(P) :- start(Start), search(Start,[Start],Q), reverse(Q,P). search(S,P,P) :- goal(S), !. /* done */ search(S,Visited,P) :- next_state(S,Nxt), /* generate next state */ ...
more »

2017-09-05 20:09 (0) Answers

Using embedded R tool in Prolog

I know with using pack 'real', we can use embedded R in Prolog. But I met problems to use this pack. And I didn't find simple examples of using this pack. Can somebody give a simple example of this pack? e.g. Loading Prolog values on to R variable...
more »

2017-06-25 15:06 (1) Answers

Prolog - days of the week

I'm new at prolog and it is messing up my head. Could you guys give me a simple example like.. the days of the week! Let's say I have a day(mon, tue, wed, thu, fri). and I wanna know in which day of the week I'm on (assuming on start it'll akways...
more »

2017-05-17 05:05 (5) Answers

prolog - BFS algorithm to solve rubik cube issue

I'm wondering how to run BFS algorithm for rubik cube that is an input parameter of my function. So far I have created functions rotateUp(cubeIn, cubeOut), rotateDown(cubeIn, cubeOut2), rotateFront(cubeIn, cubeOut), rotateBack(cubeIn, cubeOut), rotat...
more »

2017-04-29 18:04 (0) Answers

A* search in Prolog

I tried implementing a 15puzzle solver in prolog as a way to try and learn the language and take advantage of the native backtracking. I followed a few online resources and wrote this simple version of the A* algorithm. All it does is generate all t...
more »

2017-02-27 01:02 (0) Answers

prolog avoiding duplicate predicates

I was wondering whether it is possible to test whether a predicate already exists (with the same information) to then avoid the user being able to input the same information again. I have already managed to do it for a single predicate: :- dynamic(...
more »

2017-02-06 16:02 (2) Answers

Generate predicates from Json

I have a WEB API done in Asp.Net that returns some points of interest in JSON. In prolog I obtain it by doing this: poi(X):- http_client:http_get('http://localhost:XXXXX/api/PontosInteresse',X,[]). This returns something of the sort: X = '[{"ID":...
more »

2017-01-14 03:01 (1) Answers

write queries results into a file in prolog

Here is my prolog database code. :- dynamic myTable/2. init :- removeAll, asserta(myTable('avalue', 'another value')), asserta(myTable('avalue1', 'another value 1')), asserta(myTable('avalue2', 'another value 2')), asserta(m...
more »

2016-11-20 15:11 (1) Answers

List finding in a list of lists in Prolog

I want to find a specific list inside a list of lists in prolog, let's say the list is: L[L1,L2,L3......] every list inside L is in the format: L1[A,B,C,D] I want to find a Ln with the smallest A, how can I do it? ...
more »

2016-11-12 08:11 (1) Answers