Contribute Media
A thank you to everyone who makes this possible: Read More

Write Any Python Program in One Line and Only Using Lambdas!

Description

Write Any Python Program in One Line and Only Using Lambdas! - PyCon Italia 2022

Any program can be written in just one statement and only using lambda.

Sounds weird? The first claim will bring us into what functional programming is (+ map, functools…); the second one will dig into λ calculus.

But why? You will learn the power of λ and how to be concise: a better pythonist! This talk will cover:

  • Recursion! Recursion enables to write simple and concise python code. We will bring many examples of recursion, how to make it fast with memoizing and what tail call optimization is.
  • Mutable vs Immutable objects! Since FP uses a completely immutable approach, this might be the right time to learn about tuples, frozendicts, and all immutable data structures.
  • Higher order functions! You can pass functions as arguments and return them in functions. There are many functions in python that use this feature: sort, min, max, map, filter etc.
  • Functools! Functools is the standard python library containing many useful functional tools. The library functions will be all explained properly, such as partial and reduce, often used in FP.
  • Lambda calculus! λ calculus is the first functional language! In fact, a λ calculus interpreter could be written using exclusively the lambda statement (no loops, numbers, standard functions, libraries, anything).

Speaker: Niccolò «Veggero» Venerandi

Details

Improve this page