nim_iterator_stream_experiment/stream/loop/loopscope

A while scope defined by a condition and a stepper (a procedure that makes the loop go forward).

Examples.

Types

Condition[T] = Predicate[T]
  Source Edit
Stepper[S] = Reader[S, S]
  Source Edit
LoopScope[S] = object
  condition: Condition[S]
  stepper: Stepper[S]
  Source Edit

Procs

proc run[S](self: LoopScope[S]; initial: S; body: S -> Unit): S
  Source Edit
proc run[S](self: LoopScope[S]; initial: S): S
Runs the loop while doing nothing in its body.   Source Edit
proc runOnce[S; T](self: LoopScope[S]; start: S; body: S -> T): RunOnceResult[S, T]
  Source Edit
proc mapSteps[SA; SB](self: LoopScope[SA];
                    conditionMapper: Condition[SA] -> Condition[SB];
                    stepperMapper: Stepper[SA] -> Stepper[SB]): LoopScope[SB]
  Source Edit
proc mapSteps[SA; SB](self: LoopScope[SA]; extractor: SB -> SA;
                    stepperMapper: Stepper[SA] -> Stepper[SB]): LoopScope[SB]
  Source Edit
proc mapSteps[SA; SB](self: LoopScope[SA]; extractor: SB -> SA; wrapper: SA -> SB): LoopScope[
    SB]
  Source Edit

Funcs

func condition[T](predicate: Predicate[T]): Condition[T]
  Source Edit
func stepper[S](reader: Reader[S, S]): Stepper[S]
  Source Edit
func looped[S](condition: Condition[S]; stepper: Stepper[S]): LoopScope[S]
  Source Edit
func looped[S](condition: Condition[S]; stepper: S -> S): LoopScope[S]
  Source Edit
func emptyLoopScope(S: typedesc): LoopScope[S]
  Source Edit
func infinite[S](stepper: Stepper[S]): LoopScope[S]
  Source Edit
func condition[S](X: typedesc[LoopScope[S]]): Lens[X, Condition[S]]
  Source Edit
func stepper[S](X: typedesc[LoopScope[S]]): Lens[X, Stepper[S]]
  Source Edit
func asReader[S](self: LoopScope[S]; body: S -> Unit): Reader[S, S]
  Source Edit
func asReader[S](self: LoopScope[S]): Reader[S, S]
  Source Edit
func merge[SA; SB](self: LoopScope[SA]; other: LoopScope[SB]): LoopScope[Pair[SA, SB]]

Merges self and other into a single LoopScope.

The returned LoopScope will stop when either self or other stops.

Since 0.4.0.

  Source Edit
func breakIf[S](self: LoopScope[S]; predicate: Predicate[S]): LoopScope[S]
  Source Edit

Templates

template stepType[S; ](X: typedesc[LoopScope[S]]): typedesc[S]
  Source Edit
template stepType[S; ](self: LoopScope[S]): typedesc[S]
  Source Edit