diff --git a/src/impl_constructors.rs b/src/impl_constructors.rs index b5cd24300..cb39f8e9b 100644 --- a/src/impl_constructors.rs +++ b/src/impl_constructors.rs @@ -336,6 +336,20 @@ where /// visited in arbitrary order. /// /// **Panics** if the product of non-zero axis lengths overflows `isize`. + /// + /// ``` + /// use ndarray::{Array, arr2}; + /// + /// // Create a table of i × j (with i and j from 1 to 3) + /// let ij_table = Array::from_shape_fn((3, 3), |(i, j)| (1 + i) * (1 + j)); + /// + /// assert_eq!( + /// ij_table, + /// arr2(&[[1, 2, 3], + /// [2, 4, 6], + /// [3, 6, 9]]) + /// ); + /// ``` pub fn from_shape_fn(shape: Sh, f: F) -> Self where Sh: ShapeBuilder,