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

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.

主站蜘蛛池模板: 秭归县| 河西区| 本溪| 栾城县| 江源县| 佛教| 阜南县| 安义县| 咸阳市| 潜山县| 平武县| 卢龙县| 大安市| 全椒县| 临湘市| 水城县| 舟山市| 新竹县| 卓尼县| 鸡东县| 灵山县| 新平| 拉萨市| 浑源县| 郑州市| 乌鲁木齐县| 台北市| 长葛市| 隆昌县| 达孜县| 佛山市| 柘荣县| 新龙县| 大余县| 江源县| 霸州市| 伊吾县| 邵东县| 钟山县| 刚察县| 阿坝县|