OCaml Findings
Programming ngram sensor data models in OCaml exercised various language features.
-- String continuation -- breaking long strings across the lines
-- glues it together without the leading spaces.
Using, as a parameter, a function with optional parameters, and using them, requires that the function type is fully known. Example is from cells/genlm.ml:
-- String continuation -- breaking long strings across the lines
“he\
llo”
-- glues it together without the leading spaces.
Using, as a parameter, a function with optional parameters, and using them, requires that the function type is fully known. Example is from cells/genlm.ml:
let dirwalk (f:?mincount:int -> ?date:string -> string -> unit) ?date root =
let numbers = Str.regexp "^[0-9]+$" in
let subdirs = Array.to_list (Sys.readdir root) in
let subdirs = List.filter (fun x -> Str.string_match numbers x 0 && x <> "0") subdirs in
(* let subdirs = ["9"] in *)
match date with
| Some date ->
List.iter (fun x -> f (Filename.concat root x) ~date:date) subdirs
| None ->
List.iter (fun x -> f (Filename.concat root x)) subdirs
Comments