MCPcopy Create free account
hub / github.com/Euphrasiologist/nu_plugin_plot / min_max

Function min_max

src/lib.rs:134–142  ·  view source on GitHub ↗

Return the minimum and the maximum of a slice of `f32`.

(series: &[f32])

Source from the content-addressed store, hash-verified

132
133/// Return the minimum and the maximum of a slice of `f32`.
134fn min_max(series: &[f32]) -> (f32, f32) {
135 let min = series
136 .iter()
137 .fold(std::f32::MAX, |accu, &x| if x < accu { x } else { accu });
138 let max = series
139 .iter()
140 .fold(std::f32::MIN, |accu, &x| if x > accu { x } else { accu });
141 (min, max)
142}
143
144/// Get the type of a `Value`, and its length if it's a list.
145fn get_value_type_or_list_length(val: &Value) -> (Type, Option<usize>) {

Callers 2

plotMethod · 0.85
plot_nestedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected