I have in my file a few predicates.
cam_curto(User1,User2,Cam):-cam_curto(User1,User2,[User1],Cam).
cam_curto(User1,User1,LA,Cam):-reverse(LA,Cam).
cam_curto(User1,User2,LA,Cam):- liga(User1,Z,_,_), \+ member(Z,LA), cam_curto(Z,User2,[Z|LA],Cam).
mais_curto(UserA,UserB,CamCurto):- findall((Tam,Caminho),(cam_curto(UserA,UserB,Caminho),length(Caminho,Tam)),LSol), sort(LSol,LSolOrd),reverse(LSolOrd , ListaFinal), ListaFinal=[(_,CamCurto)|_],!.
The real doubt is not about the prolog in itself because we tested it and it works!
But in my C# app I want to call the predicate mais_curto(UserA,UserB,CamCurto)
CamCurto
being a list with the shortest path between the 2 users.
In C# how can I get the result list?
public static List<int> caminhoMaisCurto(int iduser1, int iduser2)
{
List<int> ret = new List<int>();
PlQuery q = new PlQuery("cam_curto(" + iduser1 + "," + iduser2 + ",C).");
foreach(PlTermV v in q.Solutions)
{
}
return ret;
}
The foreach just runs forever and never stops! I don't know why. I tried so many things but I think this is the right approach. Can someone help me?