From 52947a60467ebb10cec57ffc1725644ad605c671 Mon Sep 17 00:00:00 2001
From: acondolu <andrea.condoluci@unibo.it>
Date: Fri, 14 Jul 2017 14:38:08 +0200
Subject: [PATCH] Re-use Util.index_of

---
 ocaml/Makefile  | 2 +-
 ocaml/parser.ml | 9 ++-------
 2 files changed, 3 insertions(+), 8 deletions(-)

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)
 ;;
 
-- 
2.39.2