Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file CCLazy_list.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110(* This file is free software, part of containers. See file "license" for more details. *)(** {1 Lazy List} *)type+'at='anodelazy_tand+'anode=|Nil|Consof'a*'atletempty=Lazy.from_valNilletreturnx=Lazy.from_val(Cons(x,empty))letis_empty=function|(lazyNil)->true|(lazy(Cons_))->falseletconsxtl=Lazy.from_val(Cons(x,tl))lethead=function|(lazyNil)->None|(lazy(Cons(x,tl)))->Some(x,tl)letlengthl=letrecauxaccl=matchlwith|(lazyNil)->acc|(lazy(Cons(_,tl)))->aux(acc+1)tlinaux0lletrecmap~fl=lazy(matchlwith|(lazyNil)->Nil|(lazy(Cons(x,tl)))->Cons(fx,map~ftl))letfilter~fl=letrecauxfl=matchlwith|(lazyNil)->Nil|(lazy(Cons(x,tl)))whenfx->Cons(x,lazy(auxftl))|(lazy(Cons(_,tl)))->auxftlinlazy(auxfl)letrectakenl=lazy(matchlwith|_whenn=0->Nil|(lazyNil)->Nil|(lazy(Cons(x,tl)))->Cons(x,take(n-1)tl))letrecappendab=lazy(matchawith|(lazyNil)->Lazy.forceb|(lazy(Cons(x,tl)))->Cons(x,appendtlb))letrecflat_map~fl=lazy(matchlwith|(lazyNil)->Nil|(lazy(Cons(x,tl)))->letres=append(fx)(flat_map~ftl)inLazy.forceres)letdefault~defaultl=lazy(matchlwith|(lazyNil)->Lazy.forcedefault|(lazyl)->l)moduleInfix=structlet(>|=)xf=map~fxlet(>>=)xf=flat_map~fxlet(<|>)ab=default~default:baendincludeInfixtype'agen=unit->'aoptionletrecof_geng=lazy(matchg()with|None->Nil|Somex->Cons(x,of_geng))letrecof_list=function|[]->empty|x::tl->consx(of_listtl)letto_list_revl=letrecauxacc=function|(lazyNil)->acc|(lazy(Cons(x,tl)))->aux(x::acc)tlinaux[]lletto_listl=List.rev(to_list_revl)letto_genl=letl=reflinfun()->match!lwith|(lazyNil)->None|(lazy(Cons(x,tl)))->l:=tl;Somex