print(mymap(abs[- - ])print(mymap(pow[ ][ ])this version relies heavily upon the special *args argument-passing syntax--it collects multiple sequence (reallyiterableargumentsunpacks them as zip arguments to combineand then unpacks the paired zip results as arguments to the passed-in function that iswe're using the fact that the zipping is essentially nested operation in mapping the test code at the bottom applies this to both one and two sequences to produce this output--the same we would get with the built-in map (this code is in file mymap py in the book' examples if you want to run it live)[ [ reallythoughthe prior version exhibits the classic list comprehension patternbuilding list of operation results within for loop we can code our map more concisely as an equivalent one-line list comprehensionusing list comprehension def mymap(func*seqs)return [func(*argsfor args in zip(*seqs)print(mymap(abs[- - ])print(mymap(pow[ ][ ])when this is run the result is the same as beforebut the code is more concise and might run faster (more on performance in the section "timing iteration alternativeson page both of the preceding mymap versions build result lists all at oncethoughand this can waste memory for larger lists now that we know about generator functions and expressionsit' simple to recode both these alternatives to produce results on demand insteadusing generatorsyield and def mymap(func*seqs)res [for args in zip(*seqs)yield func(*argsdef mymap(func*seqs)return (func(*argsfor args in zip(*seqs)these versions produce the same results but return generators designed to support the iteration protocol--the first yields one result at timeand the second returns generator expression' result to do the same they produce the same results if we wrap them in list calls to force them to produce their values all at onceprint(list(mymap(abs[- - ]))print(list(mymap(pow[ ][ ])) comprehensions and generations