o ,º]š$ã@sÒdZddlmZmZmZddlmZmZddlZddlm Z ddl m Z dd„Z e rRddl Z d d „Zd d „Zd d„Zdd„ZeZeZeZddlmZeZgd¢ZdSddlZejZejZejZejZejZgZdS)a, This module is designed to be used as follows:: from past.builtins.noniterators import filter, map, range, reduce, zip And then, for example:: assert isinstance(range(5), list) The list-producing functions this brings in are:: - ``filter`` - ``map`` - ``range`` - ``reduce`` - ``zip`` é)ÚdivisionÚabsolute_importÚprint_function)ÚchainÚstarmapN)Ú basestring)ÚPY3cCst t||ƒ¡S©N)rÚ from_iterableÚmap)ÚfÚitems©rú list, tuple, or string Return those items of sequence for which function(item) is true. If function is None, return the items that are true. If sequence is a tuple or string, return the same type, else return a list. é)ÚtypeÚ isinstancerÚjoinÚbuiltinsÚfilterÚtupleÚlist)ÚargsÚmytyperrrÚ oldfilter$s rc Gs’tj|Ž}t|ƒ}t|ƒdkrgS|dur|}ntt||ƒƒ}ztdd„|Dƒƒdkr3tt |¡ƒWSW|StyH}zWYd}~|Sd}~ww)a map(function, sequence[, sequence, ...]) -> list Return a list of the results of applying the function to the items of the argument sequence(s). If more than one sequence is given, the function is called with an argument list consisting of the corresponding item of each sequence, substituting None for missing values when not all sequences have the same length. If the function is None, return a list of the items of the sequence (or a list of tuples if more than one sequence). Test cases: >>> oldmap(None, 'hello world') ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'] >>> oldmap(None, range(4)) [0, 1, 2, 3] More test cases are in test_past.test_builtins. rNcSsg|]}t|ƒ‘qSr)Úlen)Ú.0ÚitemrrrÚ Xszoldmap..r) Ú itertoolsÚ zip_longestrrrÚmaxrr Ú TypeError)ÚfuncÚ iterablesÚzippedÚlÚresultÚerrrÚoldmap8s"  ÿý €ýr*cOóttj|i|¤ŽƒSr )rrÚrange©rÚkwargsrrrÚoldrangeûór/cOr+r )rrÚzipr-rrrÚoldzipþr0r2)Úreduce)rr r,r3r1)Ú__doc__Ú __future__rrrr rrÚ past.typesrÚ past.utilsrrrrr*r/r2rr r,Ú functoolsr3r1Ú__all__Ú __builtin__rrrrÚs6  D