Skip to main content

iterate

Function iterate 

Source
pub fn iterate<X: Iterate, E>(
    seed: X,
    answer: X,
    steps: usize,
    repeat: Repeat,
    settle: impl Fn(&X) -> (X, X),
    step: impl FnMut(&X) -> Result<Step<X>, E>,
) -> Result<Iterated<X>, E>
Expand description

Iterates step from seed at most steps times. Each Step::Next is made into the next seed and the answer by settle — typically the iterate sharpened and clamped into a domain, and the iterate clamped (sharpen before clamping: clamped’s comparisons are exact on a sharp value, so the seed stays in the domain). answer is what is returned as the answer if no step is taken. The iteration stops early, with the result it would have reached, where repeat says.