[eclipse-clp-users] Array Access

From: Mark Wallace <mark.wallace_at_...44...>
Date: Wed, 15 Apr 2009 09:09:24 +1000
Hi,
I just wrote a predicate to convert a 1-dimensional array to 2D.

array2d(Row,Col,Array,Matrix) :-
    dim(Matrix,[Row,Col]),
    ( for(Index, 1, Row*Col), param(Col,Array,Matrix)
      do
          R is ((Index-1) // Col) + 1,
          C is ((Index-1) mod Col) + 1,
          Array[Index] #= Matrix[R,C]
    ).

The simplest way to match the entries seems to be by using the ic solver:
Array[Index] #= Matrix[R,C]
but the solver itself isn't needed.
Is there a nice  way to do this without using the ic solver?

    Cheers
        Mark

-- 
Professor Mark Wallace
Room 6.43
Faculty of Information Technology
Building H
Monash University
Caulfield

Tel: 34276
Received on Tue Apr 14 2009 - 23:09:26 CEST

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