Reputation: 1043
I need help making sense of Rust's ndarray
remove_index()
function. For example, I have a 3x3 two dimensional array:
use ndarray::{arr2};
let mut arr = arr2([1, 2, 3],
[4, 5, 6],
[7, 8, 9]);
I would like to remove the element with a value 5
at position [1,1]
. How do I do that with the remove_index()
function? I don't understand, how do I specify the axes and indices of a 2D array.
arr.remove_index(...);
Upvotes: 1
Views: 296
Reputation: 3758
You could swap the item to be deleted to the edge:
arr.swap([1, 1], [1, 2]); // [1, 2, 3],
// [4, 6, 5],
// [7, 8, 9]
arr.swap([1, 1], [2, 1]); // [1, 2, 3],
// [4, 8, 6],
// [7, 5, 9]
Upvotes: 0