You are on page 1of 1

Functional Python

Functional Rules
A lot of the power of functional programming comes from following some simple rules and
best practices. Let's go over those so we can know what to do and what to avoid.
Functional programming is a popular approach in a lot of languages and is even the main
approach in some. If you find you like functional programming, check out the languages
Haskell and Scala.
The rules

Computation is the evaluation of functions

Programming is done with expressions

No side-effects from computation

Functions are first-class citizens

Functions should be limited in scope and functionality

global and nonlocal let you work with variables from a higher scope. You should have

a really good reason before using either of these!

global
and
nonlocal
docs

Functional Workhorses
Now that we know the rules of functional programming, let's meet the tools we'll use the
most. We'll also see how each of these utilities helps us stick to the rules of functional
programming better.

The Lambda Lambada


Functional programming is home to a couple of odd but very useful utilities that you should
know about. You might not use these items every day, but when you need them, you'll be
very happy to have them.

You might also like