From: acondolu Date: Fri, 14 Jul 2017 12:38:08 +0000 (+0200) Subject: Re-use Util.index_of X-Git-Tag: weak-reduction-separation~41 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=c7edc9196105398f935954a7ff739cbe5382af47;p=fireball-separation.git Re-use Util.index_of (cherry picked from commit 52947a60467ebb10cec57ffc1725644ad605c671) --- diff --git a/ocaml/Makefile b/ocaml/Makefile index f54b103..198855f 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -1,6 +1,6 @@ OCAMLC = ocamlopt -g -rectypes LIB = unix.cmxa str.cmxa -UTILS = parser.cmx console.cmx listx.cmx util.cmx pure.cmx num.cmx +UTILS = util.cmx parser.cmx console.cmx listx.cmx pure.cmx num.cmx all: a.out test4.out # test.out diff --git a/ocaml/parser.ml b/ocaml/parser.ml index 90cda05..b496070 100644 --- a/ocaml/parser.ml +++ b/ocaml/parser.ml @@ -14,17 +14,12 @@ let isAlphaNum c = let n = Char.code c in (48 <= n && n <= 90) || (95 <= n && n <= 122) ;; let isSpace c = c = ' ' || c = '\n' || c = '\t' ;; -let rec index_of x = - function - | [] -> raise (Failure "index_of: Not Found") - | h::t -> if x = h then 0 else 1 + index_of x t -;; (* FIXME *) let mk_var' (bound, free) x = if List.mem x bound - then free, mk_var (index_of x bound) + then free, mk_var (Util.index_of x bound) else if List.mem x free - then free, mk_var (List.length bound + index_of x free) + then free, mk_var (List.length bound + Util.index_of x free) else (free @ [x]), mk_var (List.length bound + List.length free) ;;