是否有一个术语用于集合类型的链式处理,尤其是列表、集合和映射?
Is there a term for chained processing of collections types especially lists , sets, and maps?
考虑 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
我想 term/way 概括地描述一系列的集合处理步骤。有这样的名词吗?
Martin Fowler 使用术语 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,这是 pipe and filter 软件架构模式的特例:
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.
考虑 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
我想 term/way 概括地描述一系列的集合处理步骤。有这样的名词吗?
Martin Fowler 使用术语 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,这是 pipe and filter 软件架构模式的特例:
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.