Lecture overview -- Keyboard shortcut: 'u'  Previous page: The mapping function -- Keyboard shortcut: 'p'  Next page: Filtering -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 22 : 35
Programming Paradigms
Recursion and Higher-order Functions
Examples of mapping

We will now study a number of examples.

Expresion

Value

(map 
  string?
  (list 1 'en "en" 2 'to "to"))
(#f #f #t #f #f #t)
(map 
   (lambda (x) (* 2 x))
   (list 10 20 30 40))
(20 40 60 80)

In the first row we map the string? predicate on a list of atoms (number, symbols, and strings). This reveals (in terms of boolean values) which of the elements that are strings. In the second row of the table, we map a 'multiply with 2' function on a list of numbers.