info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Info-gnuprologjava] PrologCode.SUCCESS_LAST ¿bug?


From: Juan Galán Páez
Subject: [Info-gnuprologjava] PrologCode.SUCCESS_LAST ¿bug?
Date: Wed, 9 May 2012 12:08:27 +0200

Hi

Congrats again por the project.
I wrote here last year, but my project has been stopped until now. I took it again in the last weeks and the first alpha version is relesed (http://www.cs.us.es/~fsancho/NetProLogo/?p=about). It is a extension por NetLogo (a popular agent based modeling platform), your library was really helpful for this task.

I have the following problem.

I need somehow to know if there are reminning solutions to read when executing a query. I think it would be possible to solve this in a tricky way by previously computing and storing the solution to be returnet in a future call, but i preffer to avoid this.
I have been playing a bit with the codes returned by 'execute' and i never get 'PrologCode.SUCCESS_LAST' (1). I just get 'PrologCode.SUCCESS' (0) and when there aren't more solutions 'PrologCode.FAIL' (-1). So, am I doing something wrong? or is it a bug? is there any alternative?, i suppose it does'nt exist something like '<boolean> hasMoreSolutions(goal)'.

To show an example, here is a simple case:

PROLOG CODE:

permutation([],[]).
permutation(L1,[X|L2]) :-
             select1(X,L1,L3),
             permutation(L3,L2).
             
select1(H,[H|T],T).
select1(X,[H|T],[H|T1]) :- select1(X,T,T1).

PROLOG CALL:

permutation([a,b,c],L)

OUTPUT(last lines):

4 Code: 0
[c,a,b]
5 Code: 0
[c,b,a]
6 Code: -1
L

Thank you
Juan Galan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]