Re: Passing a list as a argument via C
Emanuele Bastianelli <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAMMJy4AGkRnys25b4_xxEHO-S11s5HfMiRYg+Pcbv5LruSYHLw@mail.gmail.com> |
So, problem solved. It seems like Prolog is very sensitive to how the string representing the list is formatted (it comes from a Python script). I had to remove single quotes and trim every entry, then it worked. Thank you anyway! 2013/7/22 Emanuele Bastianelli <[email protected]> > Hi to all, > > I've a little problem with my C interface to Prolog. > I need to pass a list as an argument to my Prolog query, and i tried to > use PlTail but it didn't work. > This is my code: > > PlTermv argomentiVar((int)req.arg.size()); > > for(int i=0; i<(int)req.arg.size(); ++i){ > if (req.arg[i][0] == '[') > { > > PlTail list(argomentiVar[i]); > string substring = req.arg[i].substr(1,req.arg[i].length()-2); > char* tokens = strtok((char *)substring.c_str(), ","); > while(tokens != NULL) { > list.append(tokens); > tokens = strtok(NULL,","); > > } > list.close(); > } > } > > PlString PlS = PlString(req.predicate.c_str()); > PlQuery eF(PlS, argomentiVar); > > I want PlTail to be an argument of tipe list, as for the query eF, for > example [a,b,c,d]. > > Thank you > -------------- next part -------------- HTML attachment scrubbed and removed