Commits

camlspotter  committed 9f51511 Merge

update

  • Participants
  • Parent commits 781fe5d, cce4ed2

Comments (0)

Files changed (8)

 
 #|Add dependencies of any build activity of this directory over $(files).
 #
-# .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
+# .. 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)
   # CR jfuruse: I guess we do not need the following
   # export # export the implicit rule above
 
-  .DEFAULT: $(library_name).cmo $(library_name).cmx $(library_name).cma $(library_name).cmxa $(MyOCamlPackageExtras)
+  .PHONY: install-lib
+  install-lib: $(library_name).cmo $(library_name).cmx $(library_name).cma $(library_name).cmxa $(MyOCamlPackageExtras)
 
   $(CMA) $(CMXA) $(library_name).a $(CSTUBLIBRARIES) : $(CSTUBS) $(CMOS) $(CMXS)
       if $(not $(equal $(cmodules), $(EMPTY)))
   export # The above thing is local: need to be exported
 
   # CR jfuruse: forgot to add the deps over the packages!
-  .DEFAULT: $(OCamlLibrary $(name), $(files))
+  install-lib: $(OCamlLibrary $(name), $(files))
 
   # The following clean the files twice if MyOCamlPacakge coexists,
   # but who cases ?

File lib/OMakefile

    zlist
    file
    comopt
+   overload
    spot
 
 LIB = spotlib
 
 let imp_ init f = fst (imp init f)
  
+(* Printf *)
+let sprintf = Printf.sprintf

File lib/base.mli

       then run the function [f] over this reference.
       It returns the final contents of the reference.
   *)
+
+val sprintf : ('a, unit, string) format -> 'a
 module File = File
 module Comopt = Comopt
 module Zlist = Zlist
+module Overload = Overload
 
 module List = struct
   include List

File lib/xlist.ml

       | Some v -> Some v
       | None -> find_map_opt f xs
 
+(** mapMaybe of Haskell *)
 let rec filter_map f lst =
   List.rev (List.fold_left (fun st x ->
     match f x with
     | Some v -> v :: st
     | None -> st) [] lst)
+
+let take n xs =
+  let rec take_ n st xs =
+    if n = 0 then st
+    else match xs with
+    | [] -> st
+    | x::xs -> take_ (n-1) (x::st) xs
+  in
+  List.rev (take_ n [] xs)
+
+let rec drop n xs =
+  if n = 0 then xs
+  else match xs with
+  | [] -> []
+  | _::xs -> drop (n-1) xs
+
+let span p xs =
+  let rec span_ st = function
+    | [] -> List.rev st, []
+    | x::xs when p x -> span_ (x::st) xs
+    | l -> List.rev st, l
+  in
+  span_ [] xs

File lib/xlist.mli

 
 val find_opt : ('a -> bool) -> 'a list -> 'a option
 val find_map_opt : ('a -> 'b option) -> 'a list -> 'b option
+
 val filter_map : ('a -> 'b option) -> 'a list -> 'b list
+
+val take : int -> 'a list -> 'a list
+val drop : int -> 'a list -> 'a list
+val span : ('a -> bool) -> 'a list -> 'a list * 'a list

File lib/xprintf.mli

       string. Otherwise it raises Invalid_argument.
   *)
 
-