Skip to main content

triangle

Macro triangle 

Source
macro_rules! triangle {
    ( $( [ $( $val:expr ),+ $(,)? ] ),+ $(,)? ) => { ... };
}
Expand description

Declarative constructor for a validated square cumulative Triangle from upper-triangle rows (coercing integer or float literals to f64).

Returns Result<Triangle, ValidationError>.

ยงExample

use reserving_kernels::{prelude::*, triangle};

let tri = triangle![
    [100, 160, 195, 205],
    [120, 190, 232],
    [135, 218],
    [150],
]?;
assert_eq!(tri.n(), 4);
assert_eq!(tri.latest_diagonal(), vec![205.0, 232.0, 218.0, 150.0]);