Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Functional Python Programming
  • Toc
  • feedback
Functional Python Programming

Functional Python Programming

By : Steven F. Lott
4 (9)
close
Functional Python Programming

Functional Python Programming

4 (9)
By: Steven F. Lott

Overview of this book

This book is for developers who want to use Python to write programs that lean heavily on functional programming design patterns. You should be comfortable with Python programming, but no knowledge of functional programming paradigms is needed.
Table of Contents (18 chapters)
close
17
Index

Chapter 4. Working with Collections

Python offers a number of functions that process whole collections. They can be applied to sequences (lists or tuples), sets, mappings, and iterable results of generator expressions. We'll look at some of Python's collection-processing functions from a functional programming viewpoint.

We'll start out by looking at iterables and some simple functions that work with iterables. We'll look at some additional design patterns to handle iterables and sequences with recursion as well as explicit for loops. We'll look at how we can apply a scalar() function to a collection of data with a generator expression.

In this chapter, we'll show examples of how to use the following functions to work with collections:

  • any() and all()
  • len() and sum() and some higher-order statistical processing related to these functions
  • zip() and some related techniques to structure and flatten lists of data
  • reversed()
  • enumerate()

The first four functions...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete