15
Functional Programming with Python Marcelo Cure

Functional programming with python

Embed Size (px)

Citation preview

Functional Programming with

Python

Marcelo Cure

Functional Programming

Expressions over statements (instead of using a whole for, use map/filter/reduce)

No side effect

Immutability

Simpler code

Expressiveness

Functional is stateless

Statefull Stateless

Don't iterate over lists

Use map/filter/reduce

A even better way

Another example with map

Another example with reduce

Lambdas

High Order Functions

Functions that manipulate functions

Send functions to functions allowing different behaviour

Function Composition

List Comprehentions

Comes from mathematics

{ x2 | x ∈ ℕ }

x * 2 given x is contained on the natural numbers

Immutability

● The same happens to other types: string, float, tuples, etc● Lists and Dictionaries are mutable● Objects are also mutable

Thanks