[eclipse-clp-users] Loop Interaction

From: Igor Kondrasovas <igor_at_inovativatec.com>
Date: Wed, 21 Apr 2010 12:00:21 -0300
Hello,

 

Currently I´m working on a predicate that I need to rewrite in order to make
it accept lists from any size. I suppose this might be solved with the help
of some built-in interaction prolog predicate. Unfortunately I still stuck
on it and not able to find what could I use. 

 

Here is the predicate:

 

solve([(X1,Y1),(X2,Y2),(X3,Y3)], [NFAB, NFAC, NFBA, NFBC, NFCA, NFCB]):-

       [X1,X2,Y1,Y2,X3,Y3] :: -10.. 10,

       outside_polygon1((X1,Y1), (X2,Y2), NFAB),

       outside_polygon1((X1,Y1), (X3,Y3), NFAC),

       outside_polygon1((X2,Y2), (X1,Y1), NFBA),

       outside_polygon1((X2,Y2), (X3,Y3), NFBC),

       outside_polygon1((X3,Y3), (X1,Y1), NFCA),

       outside_polygon1((X3,Y3), (X2,Y2), NFCB),

       search([X1,X2,Y1,Y2,X3,Y3], 0, first_fail, indomain_split, complete,
[]).

 

I would like to iterate over the input lists in order to call the
outside_polygon1 predicate no matter how long they are. As you can see, it
is not a simple “foreach” interaction.

 

I would appreciate any suggestion on how could I do that in the proper way.

 

Thanks in advance,

 

 

Igor Kondrasovas

Twitter: @ikondrasovas

Blog: http://ikondrasovas.wordpress.com

Facebook: www.facebook.com/ikondrasovas

 
Received on Wed Apr 21 2010 - 15:00:34 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET