U
    —9%eØ  ã                   @   s   d Z G dd„ dƒZdS )z
Replacement rules.
c                   @   s:   e Zd ZdZdd„ fdd„Zdd„ Zdd	„ Zddd„Zd
S )Ú	TransformaÁ  
    Immutable mapping that can be used as a generic transformation rule.

    Parameters
    ==========

    transform : callable
        Computes the value corresponding to any key.

    filter : callable, optional
        If supplied, specifies which objects are in the mapping.

    Examples
    ========

    >>> from sympy.core.rules import Transform
    >>> from sympy.abc import x

    This Transform will return, as a value, one more than the key:

    >>> add1 = Transform(lambda x: x + 1)
    >>> add1[1]
    2
    >>> add1[x]
    x + 1

    By default, all values are considered to be in the dictionary. If a filter
    is supplied, only the objects for which it returns True are considered as
    being in the dictionary:

    >>> add1_odd = Transform(lambda x: x + 1, lambda x: x%2 == 1)
    >>> 2 in add1_odd
    False
    >>> add1_odd.get(2, 0)
    0
    >>> 3 in add1_odd
    True
    >>> add1_odd[3]
    4
    >>> add1_odd.get(3, 0)
    4
    c                 C   s   dS )NT© )Úxr   r   úO/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/core/rules.pyÚ<lambda>1   ó    zTransform.<lambda>c                 C   s   || _ || _d S ©N)Ú
_transformÚ_filter)ÚselfZ	transformÚfilterr   r   r   Ú__init__1   s    zTransform.__init__c                 C   s
   |   |¡S r   )r	   )r
   Úitemr   r   r   Ú__contains__5   s    zTransform.__contains__c                 C   s    |   |¡r|  |¡S t|ƒ‚d S r   )r	   r   ÚKeyError)r
   Úkeyr   r   r   Ú__getitem__8   s    

zTransform.__getitem__Nc                 C   s   || kr| | S |S d S r   r   )r
   r   Údefaultr   r   r   Úget>   s    zTransform.get)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s
   +r   N)r   r   r   r   r   r   Ú<module>   s   