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

Summary

In this chapter, we looked closely at writing pure functions free of side effects. The bar is low here, since Python forces us to use the global statement to write impure functions. We looked at generator functions and how we can use these as the backbone of functional programming. We also examined the built-in collection classes to show how they're used in the functional paradigm. While the general idea behind functional programming is to limit the use of stateful variables, the collection objects are generally stateful and, for many algorithms, also essential. Our goal is to be judicious in our use of Python's non-functional features.

In the next two chapters, we'll look at higher-order functions: functions that accept functions as arguments as well as returning functions. We'll start with an exploration of the built-in higher-order functions. In later chapters, we'll look at techniques for defining our own higher-order functions. We'll also look at the itertools and functools modules and their higher-order functions in later chapters.

主站蜘蛛池模板: 屯门区| 涪陵区| 禄劝| 大庆市| 读书| 息烽县| 东港市| 建德市| 乐亭县| 桃源县| 宿州市| 湟源县| 项城市| 葵青区| 漯河市| 无极县| 金沙县| 平遥县| 清丰县| 清原| 巴林左旗| 博乐市| 芷江| 韩城市| 高台县| 津南区| 玉屏| 藁城市| 德化县| 秭归县| 綦江县| 吴忠市| 肥乡县| 浮梁县| 贞丰县| 班戈县| 阜阳市| 诸暨市| 定安县| 镇远县| 武平县|