Function unfold
pub fn unfold<T, #uint N>(seed: T, f: impl Fn(T) -> T) -> [T; N]Expand
Generates an array by repeatedly applying a generator function.
A seed value serves as the first output element and the base case for the generator function.
Successive elements are calculated by applying that function to the last value produced. That
way, the first element is seed, the second one is f(seed), the third one is f(f(seed)),
etc.
Examples
let empty: [(); 0] = [];
assert unfold::<(), 0>((), fn |x| x) == empty;
assert unfold::<uint<8>, 5>(1u8, fn |x| 2 *. x) == [1u8, 2u8, 4u8, 8u8, 16u8];