Creating a dynamic Prolog list of arguments with the C++ interface -


im trying create dynamic list of arguments in c++ program , call rule in prolog using c++ interface swi-prolog. it's this:

    //includes      int main     {        // other declarations        plterm   myvariable;       pltermv  myvector(3), vectorargs(2);       pltail   mylist(myvector[0]);         //here want receive texts keyboard or otherwise in char* variables        //and store in "myvector",but don't know how correctly.        //i think not work anyway.        vectorargs[0]= myvariable;       vectorargs[1]= mylist;        //myrule receives variable , list 3 interchangeable elements.       plcall ("myrule",vectorargs);         //the true program not simple xd       cout<<"\nmy variable: "<<(char *)myvariable<<'\n';         return 0;     } 

the result has "myvariable" first position of "vectorargs" , "mylist" second containing list "[text1, text2, text3]". got success using plcompound compose list, not serve resulting list constant, , need dynamic list. mean, list change in loop until program reaches end, @ moment can become "[text3, text1, text2]". @ times seems first element present in list, causing malfunction of program , rule failing. consulted documentation shows lot more c++ code embedded in prolog not, , that's i'm trying do, i'm doing queries prolog knowledge base using list, , performing actions in c++ program, based on response contained in "myvariable". lot!


Popular posts from this blog