Skip to main content

net_work

Function net_work 

Source
pub fn net_work(works: &[f64]) -> Option<f64>
Expand description

Computes the net work from a slice of work contributions.

Returns Some(0.0) for an empty slice. Returns None when any input is not finite or when the computed result is not finite.

ยงExamples

use use_work::net_work;

assert_eq!(net_work(&[10.0, -2.0, 5.0]), Some(13.0));
assert_eq!(net_work(&[]), Some(0.0));