12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970(* This file is free software, part of containers. See file "license" for more details. *)(** {1 List Zipper} *)type'at='alist*'alistletempty=[],[]letis_empty=function|[],[]->true|_->falseletto_list(l,r)=List.rev_appendlrletto_rev_list(l,r)=List.rev_appendrlletmakel=[],lletleft=function|x::l,r->l,x::r|[],r->[],rletleft_exn=function|x::l,r->l,x::r|[],_->invalid_arg"zipper.left_exn"letright=function|l,x::r->x::l,r|l,[]->l,[]letright_exn=function|l,x::r->x::l,r|_,[]->invalid_arg"zipper.right_exn"letmodifyfz=matchzwith|l,[]->(matchfNonewith|None->z|Somex->l,[x])|l,x::r->(matchf(Somex)with|None->l,r|Some_->l,x::r)letis_focused=function|_,_::_->true|_,[]->falseletfocused=function|_,x::_->Somex|_,[]->Noneletfocused_exn=function|_,x::_->x|_,[]->raiseNot_foundletinsertx(l,r)=l,x::rletremove(l,r)=matchrwith|[]->l,[]|_::r'->l,r'letdrop_before(_,r)=[],rletdrop_after(l,r)=matchrwith|[]->l,[]|x::_->l,[x]letdrop_after_and_focused(l,_)=l,[]