info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Info-gnuprologjava] How to dereference a VariableTerm by it's name


From: Juan Galán
Subject: [Info-gnuprologjava] How to dereference a VariableTerm by it's name
Date: Sat, 25 Jun 2011 13:22:06 +0200

Hello

First I want to thank the people developing this project, I find it very
useful.

I'm developing an interface between Prolog and other java based language
(NetLogo).

I've already implemented the interface for simple prolog calls like
(functionName(param1/Var1,param2/Var2,...,paramN)) and
it works properly. But it's a bit restrictive.

Now I would like to allow the interface to make more complex prolog calls
like:
findall(L,subconjunto(L,[a,b,c,d,e]),L2),length(L2,N).

For this the interface will receive a String with the prolog call
"findall(L,subconjunto(L,[a,b,c,d,e]),L2),length(L2,N)." and a Set with the
variable names I want dereference: {"L2","N"}. The problem is that I want to
avoid parsing the prolog call term by term to build the GPJ GoalTerm.

I found in the GPJ API this method: stringToTerm(String str, Environment
environment). It seems this is what I'm looking for. But now the problem is
how to dereference the variables. Normally when you build term by term the
prolog call, you keep the VaribaleTerm object and after the execution you
call the dereference method of the object. What happens if instead of the
VariableTerm object I just have the name of the variable? Is it possible to
do such I thing?

If not, I will parse term by term, but it would be easier and more flexible
if I can just execute the String and dereference the variables by their
names.

Thank You
Juan Galan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]