官术网_书友最值得收藏!

An overview of function varieties

We need to distinguish between two broad species of functions, as follows:

  • Scalar functions: They apply to individual values and compute an individual result. Functions such as abs(), pow(), and the entire math module are examples of scalar functions.
  • Collection functions: They work with iterable collections.

We can further subdivide the collection functions into three subspecies:

  • Reduction: This uses a function to fold values in the collection together, resulting in a single final value. For example, if we fold (+) operations into a sequence of integers, this will compute the sum. This can be also be called an aggregate function, as it produces a single aggregate value for an input collection.
  • Mapping: This applies a scalar function to each individual item of a collection; the result is a collection of the same size.
  • Filter: This applies a scalar function to all items of a collection to reject some items and pass others. The result is a subset of the input. 

We'll use this conceptual framework to characterize ways in which we use the built-in collection functions.

主站蜘蛛池模板: 尚义县| 泸州市| 工布江达县| 平武县| 南皮县| 兴和县| 平山县| 葵青区| 伊吾县| 濮阳市| 周宁县| 安国市| 玉林市| 宜春市| 临城县| 铜川市| 平顶山市| 巴东县| 宁明县| 轮台县| 漯河市| 玉树县| 济南市| 通海县| 庆城县| 万安县| 德庆县| 洛浦县| 新巴尔虎右旗| 崇州市| 彰化市| 辽源市| 东至县| 色达县| 宜川县| 白河县| 元谋县| 天峻县| 千阳县| 上饶县| 江都市|