JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrB +[Z @sddlmZmZddlmZddlmZGdddeZGdddeZ Gd d d e Z e e e e Gd d d e Z e e e e e Z dddZddZdS))SequenceHashable)Integral)reducec@s<eZdZdZdZddZddZddZd d Zd d Z d S) _PListBuilderzc Helper class to allow construction of a list without having to reverse it in the end. )_head_tailcCst|_t|_dS)N) _EMPTY_PLISTrr )selfr D/opt/alt/python37/lib64/python3.7/site-packages/pyrsistent/_plist.py__init__ sz_PListBuilder.__init__cCs6|js|||_|j|_n|||j_|jj|_|jS)N)r rrest)r elem constructorr r r _appends     z_PListBuilder._appendcCs||ddS)NcSs t|tS)N)PListr )er r r z+_PListBuilder.append_elem..)r)r rr r r append_elemsz_PListBuilder.append_elemcCs||ddS)NcSs|S)Nr )lr r r rrz,_PListBuilder.append_plist..)r)r plr r r append_plistsz_PListBuilder.append_plistcCs|jS)N)r)r r r r build!sz_PListBuilder.buildN) __name__ __module__ __qualname____doc__ __slots__rrrrrr r r r rs rc@seZdZdZejZejZddZddZddZ e Z dd Z d d Z d d Z e ZddZddZddZddZddZddZddZddZdS) _PListBase) __weakref__cCstt|ffS)N)plistlist)r r r r __reduce__.sz_PListBase.__reduce__cCstdd|DS)a Return the length of the list, computed by traversing it. This is obviously O(n) but with the current implementation where a list is also a node the overhead of storing the length in every node would be quite significant. css|] }dVqdS)rNr ).0_r r r :sz%_PListBase.__len__..)sum)r r r r __len__2sz_PListBase.__len__cCsdt|S)Nz plist({0}))formatr$)r r r r __repr__<sz_PListBase.__repr__cCs t||S)z Return a new list with elem inserted as new head. >>> plist([1, 2]).cons(3) plist([3, 1, 2]) )r)r rr r r cons@sz_PListBase.conscCs |}x|D]}||}q W|S)a  Return a new list with all elements of iterable repeatedly cons:ed to the current list. NB! The elements will be inserted in the reverse order of the iterable. Runs in O(len(iterable)). >>> plist([1, 2]).mcons([3, 4]) plist([4, 3, 1, 2]) )r-)r iterableheadrr r r mconsIs  z_PListBase.mconscCs*t}|}x|r$||j}|j}q W|S)a Return a reversed version of list. Runs in O(n) where n is the length of the list. >>> plist([1, 2, 3]).reverse() plist([3, 2, 1]) Also supports the standard reversed function. >>> reversed(plist([1, 2, 3])) plist([3, 2, 1]) )r#r-firstr)r resultr/r r r reverseXs   z_PListBase.reversecCsRt}|}d}x*|r8||kr8||j|j}|d7}qW|sF|tfS||fS)z Spilt the list at position specified by index. Returns a tuple containing the list up until index and the list after the index. Runs in O(index). >>> plist([1, 2, 3, 4]).split(2) (plist([1, 2]), plist([3, 4])) rr)rrr1rr r)r indexZlbZ right_listir r r splitms  z_PListBase.splitccs |}x|r|jV|j}qWdS)N)r1r)r Zlir r r __iter__sz_PListBase.__iter__cCst|tstSt|t|kS)N) isinstancer!NotImplementedtuple)r otherr r r __lt__s z_PListBase.__lt__cCsLt|tstS|}|}x(|r>|r>|j|jks0dS|j}|j}qW| oJ| S)z Traverses the lists, checking equality of elements. This is an O(n) operation, but preserves the standard semantics of list equality. F)r8r!r9r1r)r r;Z self_headZ other_headr r r __eq__s    z_PListBase.__eq__cCst|trN|jdk r>|jdkr>|jdks2|jdkr>||jStt||St|tsjt dt |j |dkr~|t |7}y ||j Stk rtdYnXdS)Nrz-'%s' object cannot be interpreted as an indexrzPList index out of range)r8slicestartstopstep_dropr#r:r TypeErrortyperlenr1AttributeError IndexError)r r4r r r __getitem__s (    z_PListBase.__getitem__cCs4|dkrtd|}x|dkr.|j}|d8}qW|S)NrzPList index out of ranger)rGr)r countr/r r r rBs  z_PListBase._dropcCs tt|S)N)hashr:)r r r r __hash__sz_PListBase.__hash__cCsNt}|}x0|r:|j|kr&||jS||j|j}q Wtd|dS)a  Return new list with first element equal to elem removed. O(k) where k is the position of the element that is removed. Raises ValueError if no matching element is found. >>> plist([1, 2, 1]).remove(1) plist([2, 1]) z{0} not found in PListN)rr1rrr ValueErrorr+)r rZbuilderr/r r r removes     z_PListBase.removeN)rrrr rrIr4r%r*r,__str__r-r0r3 __reversed__r6r7r<r=rHrBrKrMr r r r r!%s&   r!cs0eZdZdZdZfddZddZeZZS)ra Classical Lisp style singly linked list. Adding elements to the head using cons is O(1). Element access is O(k) where k is the position of the element in the list. Taking the length of the list is O(n). Fully supports the Sequence and Hashable protocols including indexing and slicing but if you need fast random access go for the PVector instead. Do not instantiate directly, instead use the factory functions :py:func:`l` or :py:func:`plist` to create an instance. Some examples: >>> x = plist([1, 2]) >>> y = x.cons(3) >>> x plist([1, 2]) >>> y plist([3, 1, 2]) >>> y.first 3 >>> y.rest == x True >>> y[:2] plist([3, 1]) )r1rcs tt||}||_||_|S)N)superr__new__r1r)clsr1rinstance) __class__r r rQsz PList.__new__cCsdS)NTr )r r r r __bool__szPList.__bool__) rrrrr rQrU __nonzero__ __classcell__r r )rTr rs  rc@s4eZdZdZddZeZeddZeddZdS) _EmptyPListr cCsdS)NFr )r r r r rU sz_EmptyPList.__bool__cCs tddS)NzEmpty PList has no first)rF)r r r r r1sz_EmptyPList.firstcCs|S)Nr )r r r r rsz_EmptyPList.restN) rrrr rUrVpropertyr1rr r r r rX s  rXr FcCs$|st|}|tdd|tS)a  Creates a new persistent list containing all elements of iterable. Optional parameter reverse specifies if the elements should be inserted in reverse order or not. >>> plist([1, 2, 3]) plist([1, 2, 3]) >>> plist([1, 2, 3], reverse=True) plist([3, 2, 1]) cSs ||S)N)r-)rrr r r r/rzplist..)r$r3rr )r.r3r r r r# s r#cGst|S)zj Creates a new persistent list containing all arguments. >>> l(1, 2, 3) plist([1, 2, 3]) )r#)elementsr r r r2srN)r F)_compatrrnumbersr functoolsrobjectrr!rregisterrXr r#rr r r r s  :(