# New Ticket Created by Vasily Chekalkin # Please include the string: [perl #54742] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=54742 >
Hello. Reworked implementation of 'map' -- Bacek
Index: src/classes/List.pir =================================================================== --- src/classes/List.pir (revision 27774) +++ src/classes/List.pir (working copy) @@ -709,6 +709,31 @@ .return 'list'(arr) .end +=item map() + +Map. + +=cut + +.sub 'map' :method + .param pmc expression + .local pmc res, elem, block, mapres, iter + + res = new 'List' + iter = new 'Iterator', self + loop: + unless iter goto done + elem = shift iter + newclosure block, expression + mapres = block(elem) + + res.'push'(mapres) + goto loop + + done: + .return(res) +.end + =back =head1 Functions @@ -768,6 +793,20 @@ .end +=item C<map> + +Operator form of C<map>. Delegates map to passed list. + +=cut + +.sub 'map' :multi(_,List) + .param pmc expression + .param pmc list + + .return list.'map'(expression) +.end + + =item C<infix:,(...)> Operator form for building a list from its arguments. @@ -1118,8 +1157,9 @@ .return list.'uniq'() .end -## TODO: join map reduce sort zip +## TODO: zip + =back =cut