I have a predicate that I use to initialise a 2D matrix in eclipse:
problem(1, [](
[](1,2,3,4),
[](1,2,4,3),
[](1,3,2,4),
)
).
I'd like to use a C++ program to interface with the set of eclipse predicates, and so I need a way to create the matrix from C++ with arbitrary values and dimensions. I can create a 1D matrix with
EC_functor matrix4("[]", 4);
EC_word r1 = term(matrix4, 1, 2, 3, 4);
EC_word r2 = term(matrix4, 1, 2, 4, 3);
EC_word r3 = term(matrix4, 1, 3, 2, 4);
and this doesn't cause any noticeable problems, but when I try to pack them into a 2d matrix it produces an error and terminates:
EC_functor matrix3("[]", 3);
EC_word table = term(matrix3, r1, r2, r3);
non-atomic initializer in ecl_refs_create()
How can I create a 2D matrix in C++ and pass it as a compound term argument?
(I couldn't find any examples of this in https://www.eclipseclp.org/doc/examples or https://eclipseclp.org/doc/embedding.pdf)
The issue was accidently not included in my example in the question, but was to change the type of objects returned by term
from EC_ref
to EC_word
.
I got confused by https://eclipseclp.org/doc/embedding.pdf#page=19 seeming to refer to interchangeability between the types.