Week 7: Exercises

1. Filtering an Array

Write a method 'filter' that takes an array a of integers and a delegate f that maps an integer to a bool. The method should return an array containing only the integers i in a for which f(i) is true.

2. Filtering an Array II

Generalize the previous method so that it will work with any kind of array.

3. Filtering a Linked List

Repeat the previous exercise, using a linked list of any type T and a delegate that maps type T to a bool.

4. Filtering a Linked List II

Repeat the previous exercise, modifying the linked list in place rather than returning a new linked list.