Top Banner
Functional Programming with Python Marcelo Cure
15

Functional programming with python

Feb 09, 2017

Download

Software

Marcelo Cure
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Functional programming with python

Functional Programming with

Python

Marcelo Cure

Page 2: Functional programming with python

Functional Programming

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

No side effect

Immutability

Simpler code

Expressiveness

Page 3: Functional programming with python

Functional is stateless

Statefull Stateless

Page 4: Functional programming with python

Don't iterate over lists

Page 5: Functional programming with python

Use map/filter/reduce

Page 6: Functional programming with python

A even better way

Page 7: Functional programming with python

Another example with map

Page 8: Functional programming with python

Another example with reduce

Page 9: Functional programming with python

Lambdas

Page 10: Functional programming with python

High Order Functions

Functions that manipulate functions

Send functions to functions allowing different behaviour

Page 11: Functional programming with python
Page 12: Functional programming with python

Function Composition

Page 13: Functional programming with python

List Comprehentions

Comes from mathematics

{ x2 | x ∈ ℕ }

x * 2 given x is contained on the natural numbers

Page 14: Functional programming with python

Immutability

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

Page 15: Functional programming with python

Thanks