0

I have a function f and a channel c

def f(i: Int) = Task.now(i + 1)

val c = channel.lift(f)

I would like to continuously apply the function f an arbitrary number of times (or indefinitely) to the output of the previous computation. I'm providing the initial value.

I can define a process p

val p = Process.emit(1).through(c)

but this only gets executed once.

How can I keep applying c to the output of the last computation ?

synapski
  • 323
  • 2
  • 12

1 Answers1

0

I can use the iterateEval[F[_], A](start: A)(f: A => F[A]) function to do that

val p = Process.iterateEval(1)(f).take(10)
synapski
  • 323
  • 2
  • 12