Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. mymap(func, lst) Given a single-argument function and a list, return a list containing the result of applying that function to each element of that

1. mymap(func, lst)

Given a single-argument function and a list, return a list containing the result of applying that function to each element of that list. For example, mymap(abs, [3,-1,4,-1,5,-9]) should return [3, 1, 4, 1, 5, 9].

2.myreduce(func, lst)

Given a two-argument function and a list, return the result of using the function repeatedly to combine all elements of the list into a single value. For example, myreduce(pow, [3,-1,4,1,-5]) should compute pow(pow(pow(pow(3, -1), 4), 1), -5) and return 3486784401.0.

Restrictions

There are several full or partial implementations of map and reduce in Python already; you may not use them. Do not import anything. Do not use the built-in function map. Do not use list comprehensions. Neither of your functions (nor the file itself) should print anything nor ask for any input.

Step by Step Solution

3.42 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

def mymapfunc lst creating new list to store result newlst looping ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

College Mathematics for Business Economics Life Sciences and Social Sciences

Authors: Raymond A. Barnett, Michael R. Ziegler, Karl E. Byleen

12th edition

321614003, 978-0321614001

More Books

Students also viewed these Finance questions

Question

5 / 4 + 9 / 2x = 3 / 8 x 1 / 4

Answered: 1 week ago