I am on the latest version of Windows 10, running with SWI-Prolog 7.6.4, and trying to get JPL (Java <->Prolog) running for a school project. I've not had to deal with path issues much but I have done my best to understand the problem. I've added the necessary import statements to my java class file, and the necessary environment variables to my system as per the page here: https://jpl7.org/DeploymentWindows However it *still* does not show up as a valid java package. I've just realized as I write this that maybe I need to reboot. I will try that after posting …

Member Avatar
Member Avatar
+1 forum 3

Hi, I have an assignment. I need to write code in logic programming language SWI-Prolog. Its very hard and I am going to appreciate if you help me :D. This is the assigment: Print 2D array size of (width x height) in spiral order. More explanation and example: You have input, width and height that are integers. With this input program needs to print a matrix "spiral" of numbers, from 1 to (height x width). Height is size of column in "spiral" matrix Width is size of row in "spiral" matrix This is just an example: spiralmatrix(w,h). /*w - width, …

Member Avatar
Member Avatar
+0 forum 2

Parser implementation Hi I am trying to implement a parser for a simple language with grammar like this. program ::= "program" declarations "begin" statements "end" declaration ::= "var" ident "as" type type ::= "string" | "int" I have the first two done, how would I write the type grammar? program( prog( DECLS, STATS ) ) --> [ 'program' ], declarations( DECLS ), [ 'begin' ], statements( STATS ), [ 'end' ]. declaration( decl( IDENT, TYPE ) ) --> [ 'var' ], ident( IDENT ), [ 'as' ], type( TYPE ).

Member Avatar
Member Avatar
+0 forum 2

Hi I am trying to implement a parser for a simple language with grammar like this. program ::= "program" declarations "begin" statements "end" declaration ::= "var" ident "as" type type ::= "string" | "int" I have the first two done, how would I write the type grammar? program( prog( DECLS, STATS ) ) --> [ 'program' ], declarations( DECLS ), [ 'begin' ], statements( STATS ), [ 'end' ]. declaration( decl( IDENT, TYPE ) ) --> [ 'var' ], ident( IDENT ), [ 'as' ], type( TYPE ).

Member Avatar
+0 forum 0

Hi, I am trying to make 8-tiles problem in prolog but my code is not running . To be more specific when I type an action then I take false. So the new state is not printed. [CODE] move([0, Y, Z], [Y, 0, Z], right). move([X, 0, Z], [0, X, Z], left). move([X, 0, Z], [X, Z, 0], right). move([X, Y, 0], [X, 0, Y], left). arc_horiz([X, Y, Z], [X1, Y, Z], Direction) :- move(X, X1, Direction). arc_horiz([X, Y, Z], [X, Y1, Z], Direction) :- move(Y, Y1, Direction). arc_horiz([X, Y, Z], [X, Y, Z1], Direction) :- move(Z, Z1, Direction). switch([[X1, …

Member Avatar
Member Avatar
+0 forum 1

at the moment I am having a problem with looping back to noun_phrase from np2. I was wondering if someone can help me loop back to nounphrase. Here is some code: noun_phrase([X|T],(det(X), NP2),Rem):- det(X), np2(T,NP2,Rem). np2([H|T],np2(adj(H),Rest),NP) :- adj(H), np2(T,Rest,Rem), noun_phrase(NP,Rem,_). I want to loop from np2 back to noun_phrase. I think the code for np2 is wrong as I just hacked it together.

Member Avatar
Member Avatar
+0 forum 1

i have been trying in vain to implement fibonacci in prolog, and so far i've done that in c++,javascript,python and java. but it just irritates me since i'm new to prolog and i just can't code much, because i haven't seen the prolog equivalents of c++'s for loops,if-else statements,basic variable usage etc.. but still i learnt whatever i could from 4-5 books i downloaded off the net, a few university lecture notes,etc. here's my code to print N elements of the fibonacci series ( here N means excluding the first two basic elements of the series, 0,1. [CODE] start:- write('Enter …

Member Avatar
Member Avatar
+0 forum 10

I am trying to find the index position of the minimum element in a list and print the element at the corresponding index position in another list. For example: [CODE] ?- min2(X,Y,[a,b,c],[5,3,7]). X= b y= 3[/CODE] Code: [CODE] min2(A,B,[A|_],[B|_]). min2(A,B,[X|T1],[Y|T2]) :- smallest(W,[Y|T2]), % using a predicate to find the min element in teh list B is W, % setting B to the result of above(i.e the min element) min2(A,B,T1,T2). % looking up position corresponding to min element in list1[/CODE] the predicate for finding the min element in the list is: [CODE] smallest(Head, [Head]). smallest(Element, [Head|Tail]) :- smallest(E, Tail), Head =< …

Member Avatar
Member Avatar
+0 forum 6

I have a code in here [CODE=prolog] location(california, usa). location('los angeles', california). location(hollywood, 'los angeles'). look_on(Country,Place) :- location(Place,X),write(X),nl, look_on(Country,X), fail.[/CODE] if i query like this one [CODE=prolog]-?look_on(Place,stamp).[/CODE] the output would be: los angeles californai usa ,can anyone help me how to display only the the last data which is the usa? im really stuck in this problem for an hour. Thanks again for the help.

Member Avatar
Member Avatar
+0 forum 1

The End.