12345678910111213141516171819202122232425262728293031323334open!Stdlibtype'arev_list=|Nil|Snocof{init:'arev_list;global_last:'a}type'arev_dlist=local_'arev_list->local_'arev_listletrecrev_list_to_list'acc=function|Nil->acc|Snoc{init;last}->rev_list_to_list'(last::acc)init;;letrev_list_to_listrl=rev_list_to_list'[]rl(* Can be thought of as the combination of [map] and composition *)letrecrev_dlist_concat_maplfacc=exclave_(* [List.fold_left (fun acc el -> f el acc) acc l], but more [local_] *)matchlwith|[]->acc|el::l->rev_dlist_concat_maplf(felacc);;letrecrev_dlist_concat_iterate_upfromto_facc=exclave_ifto_<fromthenaccelserev_dlist_concat_iterate_up(from+1)to_f(ffromacc);;letrecrev_dlist_concat_iterate_downfromto_facc=exclave_ifto_>fromthenaccelserev_dlist_concat_iterate_down(from-1)to_f(ffromacc);;