[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Info-gnuprologjava] How to dereference a VariableTerm by it's name
From: |
Daniel Thomas |
Subject: |
Re: [Info-gnuprologjava] How to dereference a VariableTerm by it's name |
Date: |
Fri, 08 Jul 2011 20:24:58 +0100 |
Hello,
Yes this can be done. You want to use the
TermReader#stringToTerm(ReadOptions options, String str, Environment
environment) method and then ReadOptions#variableNames is a map from
variable names to the associated VariableTerm.
Sorry for the delay in replying.
I hope that helps,
Daniel
On Sat, 2011-06-25 at 13:22 +0200, Juan Galán wrote:
> 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
signature.asc
Description: This is a digitally signed message part
- Re: [Info-gnuprologjava] How to dereference a VariableTerm by it's name,
Daniel Thomas <=