26. Using the higher order function reduce(), write a function max_in_list() that takes a list of numbers and returns the largest one. Then ask yourself: why define and call a new function, when I can just as well call the reduce() function directly?

Captura de pantalla 2017-02-21 a la(s) 15.28.30.png

Captura de pantalla 2017-02-21 a la(s) 15.28.49.png

27. Write a program that maps a list of words into a list of integers representing the lengths of the correponding words. Write it in three different ways: 1) using a for-loop, 2) using the higher order function map(), and 3) using list comprehensions.

Captura de pantalla 2017-02-21 a la(s) 15.46.07.png

Captura de pantalla 2017-02-21 a la(s) 15.46.19.png

28. Write a function find_longest_word() that takes a list of words and returns the length of the longest one. Use only higher order functions.

Captura de pantalla 2017-02-21 a la(s) 15.57.26.png

Captura de pantalla 2017-02-21 a la(s) 15.57.34.png

29. Using the higher order function filter(), define a function filter_long_words() that takes a list of words and an integer n and returns the list of words that are longer than n.

Captura de pantalla 2017-02-21 a la(s) 16.14.54.png

Captura de pantalla 2017-02-21 a la(s) 16.15.13.png

30. Represent a small bilingual lexicon as a Python dictionary in the following fashion {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"år"} and use it to translate your Christmas cards from English into Swedish. Use the higher order function map() to write a function translate() that takes a list of English words and returns a list of Swedish words.

Captura de pantalla 2017-02-21 a la(s) 16.48.19.png

Captura de pantalla 2017-02-21 a la(s) 16.48.40.png