3. Simple Programming. Name: map is a built-in higher-order function in Scheme that takes a function and a list as the two arguments, applies the function to each element of the list and returns a new list from that applications. For example, (map f'(1 2 3)) will be executed and returned as: '(f (1) (f 2) (f 3)). A running example of the map function: (map (lambda (x) (+ x x)) '(1 2 3)) will return '(2 4 6) (a) (8 points) Define your own function mymap that implements the same functionality of the above mentioned built-in map function. For example: (mymap (lambda (x) (+ x x)) '(1 2 3)) will return '(2 4 6) Solution: (b) (2 points) Provide a test case (similar to but not the same as the example above) of the mymap function and its result (output). Solution:
Added by Milagros T.
Close
Step 1
The lambda function `lambda x: x + x` takes an input `x` and returns `x + x`, which effectively doubles the value of `x`. Show more…
Show all steps
Your feedback will help us improve your experience
Maanya Naveen and 55 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
My library > IT 140: Introduction to Scripting v3 home > 5.1: Function basics CHALLENGE ACTIVITY 5.1.2: Basic function call. Define print_shape() to print the below shape. Example output: *** *** *** print_shape("***") print_shape() print_shape() print print_shape()
Shelayah R.
Exercise 4.3.1: Properties of functions that map ordered pairs of integers to Consider the following functions from Z * Z to Z. Which ones are onto? Justify your answer. f(x, y) = 2x - 4y f(x, y) = |x| - |y| f(x, y) = x + y - 2. f(x, y) = x^y f(x, y) = x^2y
Vincenzo Z.
Explain why this mapping is or is not a function. A. This is a function because every input maps to only one output. B. This is a function because every output maps to only one input. C. This is not a function because more than one input maps to an output. D. This is not a function because more than one output maps to an input.
Allison K.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD