12345678910111213141516171819202122232425262728293031323334353637383940(* This file is free software, part of Zipperposition. See file "license" for more details. *)(** {1 Lazy List} *)type'anode=|Nil|Consof'a*'atand'at='anodeLazy.tletnil=Lazy.from_valNilletconsab=Lazy.from_val(Cons(a,b))letof_funf=letrecauxi=lazy(matchfiwith|None->Nil|Somex->Cons(x,aux(i+1)))inaux0letrectakenl=ifn=0thennilelselazy(matchlwith|lazyNil->Nil|lazy(Cons(x,tl))->Cons(x,take(n-1)tl))letrecto_list=function|lazyNil->[]|lazy(Cons(x,f))->x::to_listfletrecto_iterresk=matchreswith|lazyNil->()|lazy(Cons(s,f))->ks;to_iterfkletrecfoldfaccres=matchreswith|lazyNil->acc|lazy(Cons(s,cont))->foldf(faccs)cont