Functional programming
monad map reduce filter
pattern matching
everything is a function and function are pure (no side effect) > consequence = more robust programs > deterministe > more testable in python, only by convention, no guarantee by the language
immutable data structures string, tuple, collections.namedTuple lazy evaluation (generator) preserve state in functions recursion instead of loops/iteration closures functools, itertools, lambda map, filter
freezing useful when debugging legacy code replace a data structe by a frozen one and python will tell you what code tried to edit the data
disadvantages
recursion is hard (harder than loop) immutable data structure may increase run times c compliqué trouver des bons devs c compliqué
In pure functional programming, the program written as a function must only work with its direct inputs, or arguments passed through the parameters. It cannot work with any other sources of information, or program state, including databases.
The key point of the functional paradigm is putting a nice wall around these stateful interactions, and distilling the functionally pure core, which is logically consistent and easy to prove to be correct.
Resources
https://youtu.be/2OdyPEY77X8 - Learn Advance Python Functional Programming - Episode 6 - AutomationCat
https://youtu.be/Ta1bAMOMFOI - Functional Programming with Python by Mike Müller
https://youtu.be/sqV3pL5x8PI - Programming Paradigms - Computerphile
https://youtu.be/eis11j_iGMs - Lambda Calculus - Computerphile
https://youtu.be/xJCPpDlk9_w?list=PLP8GkvaIxJP1z5bu4NX_bFrEInBkAgTMr - Functional Programming in Python: Immutable Data Structures - Real Python