On 06/10/11 21:48, Sergey Dymchenko wrote: > BTW, could you explain: > > term_variables(States,StatesList), % I should not do that, but I'm too > lazy to do it better ;-) well, sorry for this comment. You are pointing my laziness to the whole list! ;-) As also Thorsten pointed out, I just tried to get quickly an IP model, without trying to get a good formulation or a good code. Here States is a one-dimensional array, and I needed to convert it into a list. I should have used some other operator (e.g., =.. ) but the first thing that came to my mind was term_variables. In this particular example, it works as long as States is an array of variables. But States is also a parameter of the main predicate, so you never know how the user will actually use this predicate. If States is used only as an output parameter, the code is ok. But what if the user calls the goal: solve(3, [](1, 2, 1), [](4, X, Y)) Is the result correct? The answer is left as an exercise to the reader ;-) Cheers, Marco -- Marco Gavanelli, Ph.D. in Computer Science Dept of Engineering University of Ferrara Tel/Fax +39-0532-97-4833 http://www.ing.unife.it/docenti/MarcoGavanelli/Received on Fri Oct 07 2011 - 14:03:54 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST