【问题标题】:Is there a term for chained processing of collections types especially lists , sets, and maps?是否有集合类型(尤其是列表、集合和映射)的链式处理的术语?
【发布时间】:2019-12-20 08:27:06
【问题描述】:

考虑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

我想要一个术语/方式来概括描述一系列集合处理步骤。有这样的说法吗?

【问题讨论】:

  • 一个pipeline 可能吗?
  • @XavierGuihot 这不是特定于 collections 处理的术语。

标签: scala collections terminology


【解决方案1】:

Martin Fowler 使用术语collection pipeline

收集管道是一种编程模式,您可以在其中组织一些 计算作为一个操作序列,这些操作由一个 收集作为一个操作的输出并将其馈送到下一个操作。 (常见的操作有filter、map和reduce。)

IMO,这是pipe and filter 软件架构模式的特例:

管道和过滤器是一种连接数字的简单架构风格 处理数据流的组件,每个组件都连接到 通过管道处理管道中的下一个组件。

【讨论】:

  • 第一个显然是直接恰当的——尽管我想知道它是否是一个 dated 术语。第二个不是特定的:pipe and filter 数据可以由任何类型的进程生成,因此不是集合特定的。无论如何我都赞成,但会等待其他答案。
猜你喜欢
  • 2021-12-03
  • 1970-01-01
  • 2018-02-23
  • 1970-01-01
  • 2011-11-13
  • 2021-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多