Re: [eclipse-clp-users] Array Access

From: Chris Mears <cmears_at_...44...>
Date: Wed, 15 Apr 2009 09:25:04 +1000
Mark Wallace <mark.wallace@...44...> writes:
> I just wrote a predicate to convert a 1-dimensional array to 2D.
[...]
> Is there a nice  way to do this without using the ic solver?

What about this?

====================

a2d(Rows, Cols, Array, Matrix) :-
        dim(Matrix, [Rows, Cols]),
        ( foreachelem(X, Array),
          foreachelem(X, Matrix) do true ).

test2:-
        Vector = [](A,B,C,D,E,F,G,H,I,J,K,L),
        a2d(3,4,Vector,M),
        writeln(Vector),
        writeln(M).

====================

[eclipse 12]: test2.
[](_155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166)
[]([](_155, _156, _157, _158), [](_159, _160, _161, _162), [](_163, _164, _165, _166))

====================
Received on Tue Apr 14 2009 - 23:40:34 CEST

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