- Mastering Python
- Rick van Hattem
- 179字
- 2021-07-16 11:10:34
Functional programming
Functional programming is a paradigm that originates from the lambda calculus. Without diving too much into the lambda calculus (λ-calculus), this roughly means that computation is performed through the use of mathematical functions, which avoids mutable data and changing state of surroundings. The idea of a strictly functional language is that all function outputs are dependent only on the input and not on any external state. Since Python is not strictly a programming language, this doesn't necessarily hold true, but it is a good idea to adhere to this paradigm as mixing these can cause unforeseen bugs as discussed in Chapter 2, Pythonic Syntax, Common Pitfalls, and Style Guide.
Even outside of functional programming, this is a good idea. Keeping functions purely functional (relying only on the given input) makes code clearer, easier to understand, and better to test as there are less dependencies. Well-known examples can be found within the math
module. These functions (sin
, cos
, pow
, sqrt
, and so on) have an input and an output that is strictly dependent on the input.
- jQuery Mobile Web Development Essentials(Third Edition)
- iOS面試一戰(zhàn)到底
- MATLAB圖像處理超級學習手冊
- Java游戲服務器架構實戰(zhàn)
- Visual Basic程序設計習題解答與上機指導
- 軟件項目管理實用教程
- Python+Office:輕松實現(xiàn)Python辦公自動化
- Learning Image Processing with OpenCV
- Java語言程序設計實用教程(第2版)
- Beginning PHP
- 你好!Python
- ASP.NET Core 2 High Performance(Second Edition)
- C#程序設計基礎與實踐
- Mastering VMware vSphere Storage
- SQL Server 2008數(shù)據(jù)庫應用技術(第2版)