2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
16 exception Error of string
18 (* interface functions ******************************************************)
22 let rec segments_of_string ss l s =
23 match try Some (S.index s '/') with Not_found -> None with
25 | Some i -> segments_of_string (S.sub s 0 i :: ss) (l-i-1) (S.sub s (i+1) (l-i-1))
27 let rec rev_map_concat map sep r = function
30 if r = "" then rev_map_concat map sep (map s) ss else
31 rev_map_concat map sep (map s ^ sep ^ r) ss
33 let fold_string map a s =
36 if i >= l then a else aux (succ i) (map a s.[i])
40 let rec rev_neg_filter filter r = function
43 if filter hd then rev_neg_filter filter r tl else rev_neg_filter filter (hd :: r) tl
45 let rec foldi_left mapi i a = function
47 | hd :: tl -> foldi_left mapi (succ i) (mapi i a hd) tl
49 let rec rev_map_append map l r = match l with
51 | hd :: tl -> rev_map_append map tl (map hd :: r)
53 let error s = raise (Error s)
55 let log s = P.eprintf "MaTeX: %s\n%!" s