How to do a parameter search in Prolog?

For example, a have a "database" like this: processor(pentium_g4400) :- brand('intel'), family('pentium'), series('g4400'), clock(3.3), socket('lga1151'), ram('ddr4'), cores(2), threads(2),!. If I, for instance, wou...
more »

2017-11-06 11:11 (1) Answers

making searcher in prolog

I'm trying to build a searcher, where I have an inverted index, something like indice("word1", [id1,id2,...,idN]) indice("word2", [id1,id2,...,idM]) Then, I have to search the id's of the words in a phrase, thinking that phrase is a list of words...
more »

2017-11-05 17:11 (0) Answers

Prolog grouping over control

I am trying to solve a problem by using Prolog. I got a list of facts book/2 which represent a book(title,author). ... book('Kamizelka', 'Boleslaw Prus'). book('Katarynka', 'Boleslaw Prus'). book('Kazania sejmowe', 'Piotr Skarga'). book('Konrad Wal...
more »

2017-10-14 16:10 (1) Answers

Prolog - Need help optimizing my code

I just started learning Prolog and I am doing a school task. I have written the program and it has "passed" all the test cases that have been thrown at it but the program "tester" still fails me because the time limit was exceeded. In other words my ...
more »

2017-10-08 22:10 (0) Answers

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