12345678910111213141516171819202122232425262728293031323334(* In reality, this can really be represented as a bool array.
The representation is best thought of as a list of all chars along with a
flag:
(a, 0), (b, 1), (c, 0), (d, 0), ...
characters belonging to the same color are represented by sequnces of
characters with the flag set to 0.
*)typet=Bytes.tletmake()=Bytes.make257'\000'letflattencm=letc=Bytes.create256inletcolor_repr=Bytes.create256inletv=ref0inBytes.setc0'\000';Bytes.setcolor_repr0'\000';fori=1to255doifBytes.getcmi<>'\000'thenincrv;Bytes.setci(Char.chr!v);Bytes.setcolor_repr!v(Char.chri)done;(Bytes.unsafe_to_stringc,Bytes.sub_stringcolor_repr0(!v+1),!v+1)(* mark all the endpoints of the intervals of the char set with the 1 byte *)letsplitscm=Cset.iters~f:(funij->Bytes.setcmi'\001';Bytes.setcm(j+1)'\001';)