Re: [eclipse-clp-users] Loop Interaction

From: Stefan Friese <stefan.friese_at_...255...>
Date: Wed, 21 Apr 2010 17:25:40 +0200
Hello,

it looks like you are asking for a nested loop, maybe something like
this (i did not test these lines):

%Xs = [(X1,Y1),(X2,Y2),(X3,Y3)]
%NFs = [NFAB, NFAC, NFBA, NFBC, NFCA, NFCB]
       (foreach(Pair1,Xs),
        param(Xs),
        param(NFs)
       do
          (foreach(Pair2,Xs),
           foreach(NF,NFs)
          do
            (Pair1 \== Pair2 ->
              outside_polygon1(Pair1,Pair2,NF)
            ;
              true
            )
          )
       )


Stefan

Am Mittwoch, den 21.04.2010, 12:00 -0300 schrieb Igor Kondrasovas:
> 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
> 
>  
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
Received on Wed Apr 21 2010 - 15:48:49 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST