Search code examples
scalacollectionsterminology

Is there a term for chained processing of collections types especially lists , sets, and maps?


Consider a basic collections processing sequence in scala:

val a = ((1 to 50)
  .map(_ * 4)
  .filter( _ <= 170)
  .filter(_.toString.length == 2)
  .filter (_ % 20 == 0)
  .zipWithIndex
  .map{ case(x,n) => s"Result[$n]=$x"}
  .mkString("  .. "))

  a: String = Result[0]=20  .. Result[1]=40  .. Result[2]=60  .. Result[3]=80

I would like a term/way to generally describe a sequence of collections processing steps. Is there such a term?


Solution

  • Martin Fowler uses the term collection pipeline:

    Collection pipelines are a programming pattern where you organize some computation as a sequence of operations which compose by taking a collection as output of one operation and feeding it into the next. (Common operations are filter, map, and reduce.)

    IMO, this is special case of pipe and filter software architectural pattern:

    Pipe and Filter is a simple architectural style that connects a number of components that process a stream of data, each connected to the next component in the processing pipeline via a Pipe.