macro_rules! array_arange {
(Tuple2<$t1:ty, $t2:ty>, $($tt:tt)*) => { ... };
(Tuple3<$t1:ty, $t2:ty, $t3:ty>, $($tt:tt)*) => { ... };
(List<$t1:ty>, $($tt:tt)*) => { ... };
(char, $($tt:tt)*) => { ... };
(String, $($tt:tt)*) => { ... };
($tt:ty, $n:expr, $m:expr) => { ... };
($tt:ty, $n:expr, $m:expr, $k:expr) => { ... };
}
Expand description
Create new 2d array with ones on the diagonal and zeros elsewhere
ยงExamples
use arr_rs::prelude::*;
let arr = array_arange!(i32, 0, 4).unwrap();
assert_eq!(array!(i32, [0, 1, 2, 3, 4]).unwrap(), arr);
let arr = array_arange!(i32, 0, 7, 2).unwrap();
assert_eq!(array!(i32, [0, 2, 4, 6]).unwrap(), arr);