Description
In this course, you will learn :
- How to use Python to implement functional programming.
- What functional programming is, how to use it, and which Python features support it.
- How functions behave as objects, the significance of mutability, and how to perform recursion.
- Understand the benefits and drawbacks of functional programming in Python.
- How to obtain function objects.
- Understand mutability and recursion in Python.
- How to use closures as function factories.
- Learn to tell the difference between iterators and iterables.
- Develop your skills in creating, reducing, and transforming iterables.
- List comprehensions and generator comprehensions are two types of comprehensions.
- Put function composition and partial application into action.
- Learn about functors, applicatives, and monads.
Syllabus :
1. Introduction
- Introduction to Functional Programming
- Programming Paradigms
- Functional Programming and Its Characteristics
- Advantages and Disadvantages of Functional Programming
2. Functions as Objects
- Objects and Variables in Python
- Storing Function Reference in a Variable
- Aliases
- Functions as Parameters and Return Values
- Lambda Functions
- Function Versions of Standard Operators
3. Mutability
- Mutability in Python
- The Problem With Mutable Objects: Accidental Modification
- Changing Immutable Objects
- The Problem With Immutable Objects
4. Recursion
- Introducing Recursion
- Factorials
- Recursion Limits and Tail Recursion
- Inefficient Recursion: Fibonacci Numbers
- Memoization
- Flattening Lists
5. Closures
- What Is a Closure?
- Creating Anonymous Functions
- Composing Functions
- Using Closures Instead of Classes
- Using Classes Instead of Closures
- Closure Inspection
6. Iterators
- What Is an Iterator?
- Iterables and For Loops
- Iterators vs Iterables
- Iterators Use Lazy Evaluation
- Sequences
- Realising an Iterator
- Unpacking an Iterable
- Creating Your Own Iterator
- Exercise: Create a Fibonacci Iterator
- Solution Review: Create a Fibonacci Iterator
- Built-In Functions
7. Transforming Iterables
- Enumerate
- Zip
- Filter
- Map
- Reversed
- Sorted
- Combining Functions
8. Reducing Iterables
- Len and Sum
- Min
- Max, Any and All
- Functools Reduce
- Map-Reduce Pattern
9. Comprehensions
- List Comprehensions
- List Comprehensions Using Conditions
- Nested Comprehensions
10. Generators
- How a Generator Works: Alphabet Iterator
- Exercise: Generator for Fibonacci Numbers
- Solution Review: Generator for Fibonacci Numbers
- Chaining Iterators
- Generator Comprehensions
11. Partial Application and Currying
- Closures and Partial Application
- Partial Application With functools.partial
- Applying Keyword Arguments
- Currying
- When to Use Currying?
- Composition
- Creating a Compose Function
- Libraries Supporting Composition
12. Functors and Monads
- Introducing Functors, Applicatives, and Monads
- Functors
- Applicative Functors
- Monads