/** * Loops with the specified effectual function purely for its effects. The * moral equivalent of: * * ```typescript * var s = initial * * while (cont(s)) { * body(s) * s = inc(s) * } * ``` * * @tsplus static effect/core/io/Effect.Ops loopDiscard */ export function loopDiscard( initial: Z, cont: (z: Z) => boolean, inc: (z: Z) => Z ) { return (body: (z: Z) => Effect): Effect => { return Effect.suspendSucceed(() => { return cont(initial) ? body(initial).zipRight(loopDiscard(inc(initial), cont, inc)(body)) : Effect.unit }) } }