Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Licence CC BY-NC-ND Thierry Parmentelat & Arnaud Legout

filtrer une liste

filtrage par copie

Il s’agit d’écrire une fonction all_integers qui

==========
incoming(avant) = [1, 2, 3, 4, 'spam', 5, [4, 5]]
integers trouvés = [1, 2, 3, 4, 5]
incoming(après) = [1, 2, 3, 4, 'spam', 5, [4, 5]] doit être intact
==========
incoming(avant) = [(1, 2), 3, 4, 'spam', 5, 3.0]
integers trouvés = [3, 4, 5]
incoming(après) = [(1, 2), 3, 4, 'spam', 5, 3.0] doit être intact

filtrage par effet de bord

Cette fois on veut une fonction keep_only_integers qui

==========
incoming(avant) = [1, 2, 3, 4, 'spam', 5, 'beans']
all_integers = [1, 2, 3, 4, 5]
incoming(après - intact) = [1, 2, 3, 4, 'spam', 5, 'beans']
incoming(modifié par keep_only_integers) = [1, 2, 3, 4, 5]
==========
incoming(avant) = [(1, 2), 3, 4, 'spam', 5, 'beans']
all_integers = [3, 4, 5]
incoming(après - intact) = [(1, 2), 3, 4, 'spam', 5, 'beans']
incoming(modifié par keep_only_integers) = [3, 4, 5]

solution