Commits

camlspotter committed dbb8a19

enhanced some lazy functions

Comments (0)

Files changed (4)

 OMyManagedPackages(packages) =
    return $(set-diff $(packages), $(OCAML_PREINSTALLED_PACKS))
 
-#|Add dependencies of any build activity of this directory over $(files).
-#
-# .. note:: This functions introduces implicit rules: *you may need to export it, if you use this function in a local context.*
-RequireFiles(files) =
-    .SCANNER: scan-%: $(files)
-    % : $(files)
-    export
-
-#|Add dependencies of any build activity over $(packages).
+#|Add dependencies of OCaml compiled files (cmx, cmo, etc.) over $(files).
 #
 # .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
-RequirePackages(packages) =
-    RequireFiles($(OMyManagedPackages $(packages)))
-    export
-
-#|Add dependencies of any build activity of this directory over $(targets) and their dependencies
-# Creates an intermidiate md5 memo dependencies.md5
-#
-# .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
-RequireBuild(targets) =
-    dependencies.md5: $(targets)
-        CreateCheckSum($@, $(sequence-sort $(compare), $(dependencies-all $(targets))))
-    RequireFiles(dependencies.md5)
+OCamlRequire(files) =
+    %.cmx %.cmo %.cmi %.cma %.cmxa %.annot %.spot %.spit : $(files)
     export
 
 #|Add dependencies of OCaml compiled files (cmx, cmo, etc.) over $(packages).
 
 let null = from_val Null
 let cons v t = from_val (Cons (v, t))
-let (^:) v t = lazy (Cons (v, t))
+let (^:) v t = from_val (Cons (v, t))
 
 let peek = function
   | lazy Null -> None
   | lazy Null -> failwith "tl"
   | lazy (Cons (_, xs)) -> xs
 
+let rec nth t n = 
+  if n < 0 then invalid_arg "Seq.nth"
+  else
+    match t with
+    | lazy Null -> failwith "Seq.nth"
+    | lazy (Cons (x,xs)) ->
+        if n = 0 then x
+        else nth xs (n-1)
+
 let rec init t = lazy (match t with
   | lazy Null -> failwith "init"
   | lazy (Cons (_, lazy Null)) -> Null
   | lazy Null -> failwith "fold_left1"
   | lazy (Cons (v, t)) -> fold_left f v t
 
+let rec mem k t = match t with
+  | lazy Null -> false
+  | lazy (Cons (v, t)) -> if k = v then true else mem k t
 
 
 
 val is_null : 'a t -> bool
 val hd : 'a t -> 'a
 val tl : 'a t -> 'a t
+val nth : 'a t -> int -> 'a
 
 val of_list : 'a list -> 'a t
 val to_list : 'a t -> 'a list
 val intersparse : 'a -> 'a t -> 'a t
 val concat : 'a t t -> 'a t
 val intercalate : 'a t -> 'a t t -> 'a t
+
+val mem : 'a -> 'a t -> bool
+
   else lazy (f !!v)
 
 let is_val = lazy_is_val
+
+let detuple xy = 
+  let map f = let lazy xy = xy in f xy in
+  lazy (map fst),
+  lazy (map snd)