[eclipse-clp-users] Increment variable

From: CÚdric Moonen <Cedric.Moonen_at_fmtc.be>
Date: Tue, 5 Mar 2013 14:39:19 +0000

First, I am sorry to post such a newbie question but I'm very new to Eclipse-clp and I've been reading a bit in the tutorial but couldn't find an answer to my question.

So, I'm using a Java program which is actually executing a query via the OutOfProcessEclipse::rcp method. This is a very simple query which calls a predicate to find a solution and then output this solution to a file:
findSolution(X), generateFile("Solution.txt", X)

I need to modify this query so that not only the first solution gets generated to a file, but all solutions (to different files: Solution1.txt, Solution2.txt, ... ). So, I've found that I can use findall in this way:

findall(X, findSolution(X), List), ( foreach(Inst, List) do ( sprintf(FileName, "Solution%d.txt",[Index]), generateFile(FileName, Inst) ) )

So, I need to have the Index variable to reflect the iteration count. I tried several things (use foreachelem, count, ...) but I didn't succeed in finding a way to do that.

Thank you,
Received on Tue Mar 05 2013 - 15:03:17 CET

This archive was generated by hypermail 2.2.0 : Tue Mar 05 2013 - 18:13:12 CET