linspace
Turns a range into a linearly spaced sequence of values.
-
Linspace::linspace
returns an iterator. -
Linspace::linspace_array
returns an array.
Only works on bounded ranges like Range
and RangeInclusive
.
Examples
Both of these will print [0, 25, 50, 75]
.
use *;
let x: = .linspace.collect;
assert_eq!;
println!;
let y: = .linspace_array;
assert_eq!;
println!;
assert_eq!;
Both inclusive and exclusive ranges can be used.
And these will print [0, 25, 50, 75, 100]
.
use *;
let x: = .linspace.collect;
assert_eq!;
println!;
let y: = .linspace_array;
assert_eq!;
println!;
assert_eq!;
Want a non-linear range? That's also possible. After all, Linspace::linspace
just returns an Iterator
.
use *;
let x: =
.linspace
.map
.collect;
println!;
Very convenient!