Hi Richard,

I would say in general being able to achieve what you want by composition
rather than a multitude of special stages is what we strive for with akka
streams. There is also a big difference between the regular collections and
the streams that streams might be infinite, parallell, cyclic etc, and in
those cases a zipWithIndex might not make sense.

You could also achieve what you describe with a single stage using
statefulMapConcat like this:

import scala.collection.immutable.Iterable
val flow: Flow[String, (String, Long), NotUsed] =
Flow[String].statefulMapConcat { () =>
  var index = 0L
  def next = {
    index += 1
    index
  }

  (string) => Iterable((string, next))
}


-- 
Johan Andrén
Akka Team, Lightbend Inc.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to