0

Define your own Racket function that duplicates the the functionality of map from the standard library. You may not use the built-in map function as an auxiliary function.

Input: A function name (of a function that takes a single argument) and a list of elements of the same data type compatible with the function.

Output: A new list of the original elements with the same function applied to each. Example:

(my-map sqrt '(9 25 81 49))

'(3 5 9 7)

(my-map double '(6 4 8 3))

'(12 8 16 6)

(my-map sqr '(5 7))

'(25 49)

2
  • 3
    Is this a homework question? Commented Jun 30, 2016 at 19:51
  • 1
    SO users help other users when they're stuck with an approach. We're not here to do your homework problems! Commented Jun 30, 2016 at 20:06

1 Answer 1

1

Read part three of HtDP version 2.

http://www.ccs.neu.edu/home/matthias/HtDP2e/part_three.html

In particular pay attention to section 17.1.

Some advice on starting this problem:

Write a function map-sqrt that takes a one argument, a list of numbers, as input and outputs a list of numbers (the square roots of the input numbers).

Write a function map-sqr that takes a one argument, a list of numbers, as input and outputs a list of numbers (the square of the input numbers).

These two functions are very similar. Use the approach in section 17.1 in order to see what a general map function looks like.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.