Save slices of ragged object

Hello, I am asking for help to save slices of a ragged object.

I have K groups of predictors, each contains D_k, k = 1 to K predictors. With N observations, the data in stored in R as a N by sum(D_k) matrix. This predictor matrix is ragged because D_k varies by k.

data{
int N;                                    // number of observations
int K;                                    // number of groups
array[K] int D_K;                 // number of predictors per group
matrix[N,sum(D_K)] X;       //  all predictors across groups, to be sliced
}

To take advantage of the ragged structure, I want to slice this big predictor matrix by group, i.e. X_kk.

transformed data{
      int pos = 1;           
      for(k in 1:K){
             int posend = pos + D_K[k] - 1;   
             matrix[N,D_K[k]] X_kk;
             X_kk = X[ , pos:posend];                             // I want to save X_kk
             pos = posend +1;
     }
}

However, I do not have idea how to store X_kk out of the loop.

Any suggestions? I have tried to create an array with matrix elements, but it requires the specification of dimensions of the matrices.

array[K] matrix [] X_kk;

In R, we can easily create ragged objects by not specifying the dimension, such as

ls_X <-vector(mode = "list", length = 3)
for(n in 1:3){
    ls_X[[n]] <- rep(1,n)
}