관리-도구
편집 파일: recipes.cpython-312.pyc
� t��eHc � �2 � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z ddl mZmZm Z mZmZmZmZmZmZmZmZmZ ddlmZmZmZ ddlmZ g d �Z e� Zd � Z d9d�Z!d� Z"d:d �Z#d:d�Z$d� Z%e&fd�Z'd� Z(e(Z)d� Z*d� Z+d� Z,d:d�Z-d� Z. ddl m/Z0 d� Z/e.j e/_ G d� de2� Z3d� Z4d� Z5d;d�Z6d� Z7d� Z8d � Z9d:d!�Z:d:d"�Z;d:d#�Z<d<d$�Z=d%d&�d'�Z>d:d(�Z?d)� Z@d*� ZAd+� ZBd,� ZCd-� ZDd.� ZEd/� ZFd0� ZGd1� ZHd2� ZId9d3�ZJd4� ZKd5� ZLd6� ZMd7� ZNd8� ZOy# e1$ r e.Z/Y �sw xY w)=a Imported from the recipes section of the itertools documentation. All functions taken from the recipes section of the itertools library docs [1]_. Some backward-compatible usability improvements have been made. .. [1] http://docs.python.org/library/itertools.html#recipes � N)�deque)�Sized)�reduce)�chain�combinations�compress�count�cycle�groupby�islice�product�repeat�starmap�tee�zip_longest)� randrange�sample�choice)� hexversion)(� all_equal�batched�before_and_after�consume�convolve� dotproduct� first_true�factor�flatten�grouper�iter_except� iter_index�matmul�ncycles�nth�nth_combination�padnone�pad_none�pairwise� partition�polynomial_from_roots�powerset�prepend�quantify�#random_combination_with_replacement�random_combination�random_permutation�random_product� repeatfunc� roundrobin�sieve�sliding_window� subslices�tabulate�tail�take� transpose� triplewise�unique_everseen�unique_justseenc �, � t t || � � S )z�Return first *n* items of the iterable as a list. >>> take(3, range(10)) [0, 1, 2] If there are fewer than *n* items in the iterable, all of them are returned. >>> take(10, range(3)) [0, 1, 2] )�listr ��n�iterables ��/builddir/build/BUILDROOT/alt-python312-setuptools-69.0.2-1.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pkg_resources/_vendor/more_itertools/recipes.pyr9 r9 P s � � ��x��#�$�$� c �, � t | t |� � S )a� Return an iterator over the results of ``func(start)``, ``func(start + 1)``, ``func(start + 2)``... *func* should be a function that accepts one integer argument. If *start* is not specified it defaults to 0. It will be incremented each time the iterator is advanced. >>> square = lambda x: x ** 2 >>> iterator = tabulate(square, -3) >>> take(4, iterator) [9, 4, 1, 0] )�mapr )�function�starts rC r7 r7 ` s � � �x��u��&�&rD c # �� K � t |t � r,t |t dt |� | z � d� E d{ ��� yt t || �� � E d{ ��� y7 �$7 ��w)z�Return an iterator over the last *n* items of *iterable*. >>> t = tail(3, 'ABCDEFG') >>> list(t) ['E', 'F', 'G'] r N��maxlen)� isinstancer r �max�len�iterr r@ s rC r8 r8 r sS � �� � �(�E�"��(�C��3�x�=�1�+<�$=�t�D�D�D���h�q�1�2�2�2� E��2�s! �7A"�A�A"�A �A"� A"c �R � |�t | d�� yt t | ||� d� y)aX Advance *iterable* by *n* steps. If *n* is ``None``, consume it entirely. Efficiently exhausts an iterator without returning values. Defaults to consuming the whole iterator, but an optional second argument may be provided to limit consumption. >>> i = (x for x in range(10)) >>> next(i) 0 >>> consume(i, 3) >>> next(i) 4 >>> consume(i) >>> next(i) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration If the iterator has fewer items remaining than the provided limit, the whole iterator will be consumed. >>> i = (x for x in range(3)) >>> consume(i, 5) >>> next(i) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration Nr rJ )r �nextr )�iteratorrA s rC r r � s) � �@ �y� �h�q�!� �V�H�a�� #�T�*rD c �0 � t t | |d� |� S )z�Returns the nth item or a default value. >>> l = range(10) >>> nth(l, 3) 3 >>> nth(l, 20, "zebra") 'zebra' N)rQ r )rB rA �defaults rC r$ r$ � s � � ��x��D�)�7�3�3rD c �N � t | � }t |d� xr t |d� S )z� Returns ``True`` if all the elements are equal to each other. >>> all_equal('aaaa') True >>> all_equal('aaab') False TF)r rQ )rB �gs rC r r � s( � � ���A���4�=�/��a���/�/rD c �, � t t || � � S )zcReturn the how many times the predicate is true. >>> quantify([True, False, True]) 2 )�sumrF )rB �preds rC r- r- � s � � �s�4��"�#�#rD c �, � t | t d� � S )a Returns the sequence of elements and then returns ``None`` indefinitely. >>> take(5, pad_none(range(3))) [0, 1, 2, None, None] Useful for emulating the behavior of the built-in :func:`map` function. See also :func:`padded`. N)r r �rB s rC r'