## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

chapter 5

List comprehensions

In this chapter we introduce list comprehensions, which allow many functions on lists to be defined in simple manner. We start by explaining generators and guards, then introduce the function zip and the idea of string comprehensions, and conclude by developing a program to crack the Caesar cipher.

5.1 Generators

In mathematics, the comprehension notation can be used to construct new sets from existing sets. For example, the comprehension {x2 | x ∈ {1 . . 5}} produces the set {1, 4, 9, 16, 25} of all numbers x2 such that x is an element of the set {1 . . 5}. In Haskell, a similar comprehension notation can be used ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required