Function
unfold
(b: B, f: (b: B) => Option.Option<readonly [A, B]>)
Source from the content-addressed store, hash-verified
| 4337 | * @since 2.0.0 |
| 4338 | */ |
| 4339 | export const unfold = <B, A>(b: B, f: (b: B) => Option.Option<readonly [A, B]>): Array<A> => { |
| 4340 | const out: Array<A> = [] |
| 4341 | let next: B = b |
| 4342 | while (true) { |
| 4343 | const o = f(next) |
| 4344 | if (Option.isNone(o)) { |
| 4345 | break |
| 4346 | } |
| 4347 | const [a, b] = o.value |
| 4348 | out.push(a) |
| 4349 | next = b |
| 4350 | } |
| 4351 | return out |
| 4352 | } |
| 4353 | |
| 4354 | /** |
| 4355 | * Creates an `Order` for arrays based on an element `Order`. Arrays are |
Callers
nothing calls this directly
Tested by
no test coverage detected