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

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.

主站蜘蛛池模板: 饶阳县| 油尖旺区| 宁蒗| 阜城县| 鄂州市| 富蕴县| 资溪县| 沾益县| 朔州市| 洛阳市| 蒙自县| 酉阳| 健康| 鲜城| 道真| 奎屯市| 池州市| 兴山县| 安丘市| 新田县| 巴林右旗| 乐陵市| 潮安县| 天等县| 新营市| 霍林郭勒市| 静宁县| 和政县| 台山市| 平谷区| 莫力| 通许县| 贡山| 中山市| 武清区| 乌审旗| 区。| 蒙山县| 临洮县| 穆棱市| 宁远县|