Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Python con un toque funcional
Search
Carlos Villavicencio
February 20, 2019
Programming
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Python con un toque funcional
Esta presentación fue parte del #13 meetup de Guayaquil Developers
Carlos Villavicencio
February 20, 2019
Other Decks in Programming
See All in Programming
Railsバージョンを4倍にした話
optim
0
370
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
360
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
280
APNsからLive Activityを開始する話
yumnumm
0
170
AWSに止められる覚悟してますか?
morizo_1984
2
540
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
410
phperだってパンチカードでコーディングしたい
o0h
PRO
0
340
ジョジョの世界をXRで再現する
mofurune
0
160
TechTown - Creating Composable Callables in Contemporary C++
rollbear
0
130
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
1k
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
580
WENDY [Excerpt]
tessaabrams
14
40k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
570
Thoughts on Productivity
jonyablonski
76
5.4k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Transcript
13ro. meetup Febrero 20, 2019
None
None
Python con un toque funcional
Presentación Carlos Villavicencio
[email protected]
• Software Developer @ StackBuilders •
Coordinador @ QuitoLambda • @po5i • www.linkedin.com/in/cvillavicencio
Presentando a • Interpretado • Orientado a Objetos • Alto
nivel • Legible • Tipado dinámico
Qué es programación funcional? • State-less • Inmutable • Declarativa
• Sistema de tipos • Funciones de orden superior • Funciones puras
Funciones puras A = 4 def impure_sum(b): return A +
b def pure_sum(a, b): return a + b impure_sum(6) pure_sum(4, 6)
Funciones como argumento def add(x, y): return x + y
def calculate(f, x, y): return f(x, y) calculate(add, 5, 5) calculate(lambda x, y: x + y, 5, 5) Expresión λ: Función Anónima
None
Funciones de orden superior: map new_list = [] for value
in values: new_list.append(value * 2) new_list = [x * 2 for x in values]
Funciones de orden superior: filter new_list = [] for value
in values: if value % 2 == 0: new_list.append(value) new_list = [x for x in values if x % 2 == 0]
List comprehensions? list(map(lambda x: x * 2, values)) list(filter(lambda x:
x % 2 == 0, values)) [x * 2 for x in values] [x for x in values if x % 2 == 0]
Funciones de orden superior: reduce total = 0 for value
in values: total += value from functools import reduce total = reduce(lambda accum, current: accum + current, values, 0)
Partials def add_two(b): return add(2, b) print(add_two(10)) from functools import
partial add_two = partial(add, 2) print(add_two(10)) Demo def add(a, b): return a + b
Decorators def say_hello(name): return 'Hello, {}'.format(name) def make_bold(func): def func_wrapper(name):
return '<strong>{}</strong>'.format(func(name)) return func_wrapper say_hello = make_bold(say_hello) print(say_hello('Chimuelo'))
Decorators (syntactic sugar) def make_bold(func): def func_wrapper(name): return '<strong>{}</strong>'.format(func(name)) return
func_wrapper @make_bold def say_hello(name): return 'Hello, {}'.format(name) print(say_hello('Chimuelo')) Demo
Generators • “yield” keyword • Retorna un iterador / puede
ser infinito • Recuerda el local scope • Es perezoso • Demo: https://repl.it/@po5i/PythonMeetupGenerators
Type Annotations • No se realiza chequeo antes de la
ejecución • Chequeo estático con mypy • Docs: https://docs.python.org/3/library/typing.html • Demo: https://github.com/po5i/python-and-types
• Compose • Pipe • Curry • Fold • Y
más funciones todavía • Demo Librerías funcionales: toolz
Preguntas? www.stackbuilders.com Stack Builders Ecuador @stackbuilders Gracias!