123456789101112131415161718192021222324252627282930313233343536(*****************************************************************************)(* *)(* Copyright (C) 2026 Yves Ndiaye *)(* *)(* This Source Code Form is subject to the terms of the Mozilla Public *)(* License, v. 2.0. If a copy of the MPL was not distributed with this *)(* file, You can obtain one at https://mozilla.org/MPL/2.0/. *)(* *)(*****************************************************************************)letrecremove_lastacc=function|[]->([],None)|t::[]->(List.revacc,Somet)|t::q->remove_last(t::acc)qletremove_lastl=remove_last[]lletrecmap_okf=function|[]->Result.ok[]|t::q->let(let*)=Result.bindinlet*res=ftinlet*list=map_okfqinResult.ok@@(res::list)letrecfold_okfacc=function|[]->Result.okacc|t::q->let(let*)=Result.bindinlet*acc=facctinfold_okfaccq