1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465(**************************************************************************)(* This file is part of the Codex semantics library *)(* (Union-find lattice subcomponent). *)(* *)(* Copyright (C) 2026 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 3.0 *)(* for more details (enclosed in the file LICENSE). *)(* *)(**************************************************************************)typet={start:int;(** included *)stop:int;(** excluded *)step:int}letuptostop={start=0;stop;step=1}letintervalstartstop={start;stop;step=1}letinclusive_intervalstartstop=intervalstart(stop+1)letend_iterationrn=ifr.step>0thenn>=r.stopelsen<=r.stopletreciterfrangepos=ifend_iterationrangeposthen()else(fpos;iterfrange(pos+range.step))letiterfrange=iterfrangerange.startletrecforallfrangepos=ifend_iterationrangeposthentrueelse(fpos&&forallfrange(pos+range.step))letforallfrange=forallfrangerange.startletrecexistsfrangepos=ifend_iterationrangeposthenfalseelse(fpos||existsfrange(pos+range.step))letexistsfrange=existsfrangerange.startletrecfoldfrangeposacc=ifend_iterationrangeposthenaccelse(foldfrange(pos+range.step)(fposacc))letfoldfrangeacc=foldfrangerange.startaccletsumfrange=fold(funiacc->fi+acc)range0letcountfrange=fold(funiacc->iffithenacc+1elseacc)range0letppfmt=function|{start;stop;step=1;}->Format.fprintffmt"[%d:%d["startstop|{start;stop;step}->Format.fprintffmt"[%d:%d:%d["startstopstepletto_listt=foldList.const[]|>List.revletto_seqt=letrecseqpos()=ifend_iterationtposthenSeq.NilelseSeq.Cons(pos,seq(pos+t.step))inseqt.start