31 Working with List: filtering
After reading this lesson, you will be able to:
- Remove or select items from a sequence based on their position
- Filter elements of a list that respect a given predicate
- Remove duplicated items in a sequence
In the previous lesson, you have learned how to select a single element in a sequence based on its position or features. In this lesson, you’ll continue to discover other operations you can perform on an instance of List. You’ll see how to create a new list from an existing one by selecting one of its subsections. You’ll discover how to pick elements that have specific characteristics. Finally, you’ll learn how to create a new sequence that contains no duplicated items. In the capstone, you’ll use these operations to create a subset of movies that have specific characters.
31.1 Dropping and Taking elements
In the previous lessons, you have been developing a program to store your contacts. Let’s recall that your program represents a contact record as following: