T[] extract_column(T)(T[][] data, size_t column)

{

T[] result;

foreach(row; data)

{

result~=row[column];

}

return result;

}

However, for an associative array, it would have to be:

T[U] extract_column(T, U, V)(T[U][V] data, U column)

{

T[U] result;

foreach(row; data)

{

result~=row[column];

}

return result;

}

The other option would be to require explicit instantiation, but something like this should be doable using implicit instantiation from function parameter types.

The root of the problem is that syntactially, regular arrays are T[no type]. Since D has strong typedefs, it might work to define a regular array as T[size_t], since this would be different from T[int] or T[uint], which is associative.

Report this item for cleanup