[ library(visualize_tree) | Reference Manual | Alphabetic Index ]

extract_array(+Handle, ++RowCol, ++Group, +Matrix, -List)

Convert a matrix into a list for search inside a visualization
Handle
an opaque data structure for the visualization
RowCol
atom row or col, controlling the order of items in the list
Group
integer, a group identifier
Matrix
a 2D matrix
List
a variable, will be unified with a list of terms

Description

Extract the elements of a matrix inot a list in row or column order. The entries of the list will be terms which can be used inside a search routine with visualization.

Examples

model(Matrix):-
    Matrix[1..9,1..9] :: 1..9,
    create_visualization([],Handle),
    add_visualizer(Handle,
               domain_matrix(Matrix),
               [group:1]),
    (for(I,1,9),
     param(Matrix,Method) do
        alldifferent(Matrix[I,1..9]),
        alldifferent(Matrix[1..9,I])
    ),
    (multifor([I,J],[1,1],[7,7],[3,3]),
     param(Matrix) do
        alldifferent(flatten(Matrix[I..I+2,J..J+2]))
    ),
    extract_array(Handle,row,1,Matrix,NamedList),
    root(Handle),
    search(NamedList,1,input_order,tree_indomain(Handle,_),
           complete,[]),
    solution(Handle),
    close_visualization(Handle).

See Also

extract_array / 4