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

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.

主站蜘蛛池模板: 西青区| 西城区| 北宁市| 松阳县| 荃湾区| 咸丰县| 五原县| 湘乡市| 安乡县| 洪湖市| 大姚县| 旅游| 宝山区| 蓬莱市| 新田县| 金华市| 甘南县| 禹城市| 西华县| 南阳市| 吉水县| 明光市| 巨野县| 东兰县| 华容县| 漾濞| 革吉县| 崇州市| 五大连池市| 莱阳市| 读书| 沾益县| 云浮市| 萝北县| 泽普县| 荔波县| 肇东市| 斗六市| 五莲县| 浙江省| 亳州市|