/** * A generator of collections of up to the specified size, where each * collection is generated by repeatedly applying a function to an initial * state. * * @tsplus static effect/core/testing/Gen.Ops unfoldGenN */ export function unfoldGenN( n: number, s: S, f: (s: S) => Gen ): Gen> { return n <= 0 ? Gen.constant(List.empty()) : f(s).flatMap(([s, a]) => Gen.unfoldGenN(n - 1, s, f).map((list) => list.prepend(a))) }