ó
P'—^c           @   s9  d  d l  m Z d  d l m Z m Z d d l m Z d d l m Z d d l	 m
 Z
 d d l m Z m Z d d	 d
 d d d d d d d d d d d d g Z d „  Z d „  Z d „  Z d „  Z d „  Z e
 d „ Z e
 d „ Z e
 d% d& i  d „ Z e
 e d „ Z d  „  Z d! „  Z d" „  Z d# „  Z d$ „  Z d% S('   iÿÿÿÿ(   t   __not__(   t   partialt   reducei   (   t   map(   t   get_spec(   t   EMPTY(   t	   make_funct	   make_predt   identityt
   constantlyt   callerR   t   rpartialt   func_partialt   curryt   rcurryt	   autocurryt   iffyt   composet   rcomposet
   complementt   juxtt   ljuxtc         C   s   |  S(   s   Returns its argument.(    (   t   x(    (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR      s    c            s   ‡  f d †  S(   s>   Creates a function accepting any args, but always returning x.c             s   ˆ  S(   N(    (   t   at   kw(   R   (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyt   <lambda>   t    (    (   R   (    (   R   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR	      s    c             s   ‡  ‡ f d †  S(   sA   Creates a function calling its sole argument with given *a, **kw.c            s   |  ˆ  ˆ Ž  S(   N(    (   t   f(   R   R   (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR      R   (    (   R   R   (    (   R   R   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR
      s    c            s   ‡  ‡ ‡ f d †  S(   sh   A functools.partial alternative, which returns a real function.
       Can be used to construct methods.c             s   ˆ ˆ  |  t  ˆ |  Ž  S(   N(   t   dict(   R   R   (   t   argst   funct   kwargs(    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR       R   (    (   R   R   R   (    (   R   R   R   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR      s    c            s   ‡  ‡ f d †  S(   s!   Partially applies last arguments.c             s   ˆ |  ˆ  Œ  S(   N(    (   R   (   R   R   (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   $   R   (    (   R   R   (    (   R   R   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   "   s    c            sa   ˆ t  k r$ t ˆ  ƒ \ } ‰ } n  ˆ d k r4 ˆ  Sˆ d k rM ‡  f d †  S‡  ‡ f d †  Sd S(   s4   Curries func into a chain of one argument functions.i   i   c            s   ‡ ‡  f d †  S(   Nc            s   ˆ  ˆ |  ƒ S(   N(    (   t   y(   R   R   (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   /   R   (    (   R   (   R   (   R   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   /   R   c            s   t  t ˆ  |  ƒ ˆ d ƒ S(   Ni   (   R   R   (   R   (   R   t   n(    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   1   R   N(   R   R   (   R   R!   t   _(    (   R   R!   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   '   s    c            sa   ˆ t  k r$ t ˆ  ƒ \ } ‰ } n  ˆ d k r4 ˆ  Sˆ d k rM ‡  f d †  S‡  ‡ f d †  Sd S(   sd   Curries func into a chain of one argument functions.
       Arguments are passed from right to left.i   i   c            s   ‡ ‡  f d †  S(   Nc            s   ˆ  |  ˆ ƒ S(   N(    (   R    (   R   R   (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   =   R   (    (   R   (   R   (   R   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   =   R   c            s   t  t ˆ  |  ƒ ˆ d ƒ S(   Ni   (   R   R   (   R   (   R   R!   (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   ?   R   N(   R   R   (   R   R!   R"   (    (   R   R!   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   4   s    c            sd   | p- | t  k r t ˆ ƒ n t ƒ  | | f ‰ ˆ \ ‰ ‰ ‰ ‡  ‡ ‡ ‡ ‡ ‡ ‡ f d †  } | S(   sj   Creates a version of func returning its partial applications
       until sufficient arguments are passed.c             sÓ   ˆ  |  } ˆ j  ƒ  } | j | ƒ t | ƒ t | ƒ ˆ k rL ˆ | | Ž  St | ƒ t t | ƒ ˆ @ƒ ˆ k r³ y ˆ | | Ž  SWqÏ t k
 r¯ t ˆ d ˆ d | d | ƒSXn t ˆ d ˆ d | d | ƒSd  S(   Nt   _spect   _argst   _kwargs(   t   copyt   updatet   lent   sett	   TypeErrorR   (   R   R   R   R   (   R$   R%   R   t   max_nt
   required_nt   required_namest   spec(    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyt   autocurriedI   s    
& (   R   R   R)   (   R   R!   R#   R$   R%   R/   (    (   R$   R%   R   R+   R,   R-   R.   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   C   s    0!c            sK   ˆ  t  k r t t ˆ ˆ ƒ St ˆ ƒ ‰ t ˆ  ƒ ‰  ‡  ‡ ‡ f d †  Sd S(   sB   Creates a function, which conditionally applies action or default.c            s0   ˆ |  ƒ r ˆ  |  ƒ St  ˆ ƒ r, ˆ |  ƒ Sˆ S(   N(   t   callable(   t   v(   t   actiont   defaultt   pred(    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   b   s   N(   R   R   t   boolR   R   (   R4   R2   R3   (    (   R2   R3   R4   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   [   s
    c          G   s-   |  r% d „  } t  | t t |  ƒ ƒ St Sd S(   s   Composes passed functions.c            s   ‡  ‡ f d †  S(   Nc             s   ˆ  ˆ |  | Ž  ƒ S(   N(    (   R   R   (   R   t   g(    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   j   R   (    (   R   R6   (    (   R   R6   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   j   R   N(   R   R   R   R   (   t   fst   pair(    (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   g   s    	c          G   s   t  t |  ƒ Œ  S(   s4   Composes functions, calling them from left to right.(   R   t   reversed(   R7   (    (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   o   s    c         C   s   t  t |  ƒ S(   s%   Constructs a complementary predicate.(   R   R    (   R4   (    (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   s   s    c             s"   t  t t |  ƒ ƒ ‰  ‡  f d †  S(   sa   Constructs a juxtaposition of the given functions.
       Result returns a list of results of fs.c             s    g  ˆ  D] } | |  | Ž  ^ q S(   N(    (   R   R   R   (   t   extended_fs(    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR      R   (   t   listR   R   (   R7   (    (   R:   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   {   s    c             s"   t  t t |  ƒ ƒ ‰  ‡  f d †  S(   sk   Constructs a lazy juxtaposition of the given functions.
       Result returns an iterator of results of fs.c             s   ‡  ‡ f d †  ˆ Dƒ S(   Nc         3   s   |  ] } | ˆ  ˆ Ž  Vq d  S(   N(    (   t   .0R   (   R   R   (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pys	   <genexpr>…   s    (    (   R   R   (   R:   (   R   R   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR   …   R   (   R;   R   R   (   R7   (    (   R:   s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyR      s    N(    (   t   operatorR    t	   functoolsR   R   t   compatR   t   _inspectR   t
   primitivesR   t
   funcmakersR   R   t   __all__R   R	   R
   R   R   R   R   t   NoneR   R   R   R   R   R   R   (    (    (    s-   /tmp/pip-unpacked-wheel-WgnHs6/funcy/funcs.pyt   <module>   s0   												