Re: [eclipse-clp-users] Java-Eclipse Interface, Structs.

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Sun, 11 Apr 2010 14:53:10 +1000
Maged Zamzam wrote:
> Dear all,
> I have a Struct Journal in the CP code and I want to take each item in 
> the Journal to be displayed in Java explicitly without having to parse.
> Is there a way to take the list of all Journals and convert into args??

On the Java side, a struct is represented as a CompoundTerm object
(like any compound term).  That means the arguments are identified
only by their positions, and you can access them with the arg() method.

To get the mapping of names to positions, you could make an rpc()
and call current_struct(journal, _).  This will return a compound
term with the struct field names in the corresponding positions,
which you can the use for printing.

The equivalent in ECLiPSe:

:- local struct(journal(title,year,publisher)).

?- current_struct(journal,X).
X = journal(title, year, publisher)
Yes (0.00s cpu)


-- Joachim
Received on Sun Apr 11 2010 - 04:53:15 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST