Explain what the map function does in a functional language. How does it provide additional abstraction capability in a programming language?

CMPTR
3rd Edition
ISBN:9781337681872
Author:PINARD
Publisher:PINARD
Chapter20: Creating A Presentation
Section: Chapter Questions
Problem 5QY
Question

1.14 Explain what the map function does in a functional language. How does it provide additional abstraction capability in a programming language?

Expert Solution
Step 1

The map function builds and returns a list of the results got by applying the argument function to every element in the argument list.

The function expects another function and a collection, like a list as arguments.

Step 2

Example using Lisp:

The first argument to the map is the function abs, which returns the absolute value of its arguments. The second argument to map is a list generated by the function list.

(map abs (list 33 -10 66 88 -4) )                                  ; Returns (33 10 66 88 4)

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT