package spin
OCaml project generator
Install
Dune Dependency
Authors
Maintainers
Sources
opam-spin-0.8.3.tbz
sha256=eeef9d3b89cca796d8d47ba425cee131bf14b5b0f1349927c4d8b22297b1f6b6
sha512=1850cad87f180b37e658e716986f6aa0ba76e57d6638d40b8f6e8ae2c6f60deee82218464e02356632022b394f49cc5a341e7255112aef455ffec9ca2db4cc32
doc/src/spin.std/glob.ml.html
Source file glob.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
(* From https://github.com/simonjbeaumont/ocaml-glob *) let split c s = let len = String.length s in let rec loop acc last_pos pos = if pos = -1 then String.sub s 0 last_pos :: acc else if s.[pos] = c then let pos1 = pos + 1 in let sub_str = String.sub s pos1 (last_pos - pos1) in loop (sub_str :: acc) pos (pos - 1) else loop acc last_pos (pos - 1) in loop [] len (len - 1) (** Returns list of indices of occurances of substr in x *) let find_substrings ?(start_point = 0) substr x = let len_s = String.length substr and len_x = String.length x in let rec aux acc i = if len_x - i < len_s then acc else if String.sub x i len_s = substr then aux (i :: acc) (i + 1) else aux acc (i + 1) in aux [] start_point let matches_glob ~glob x = let rec contains_all_sections = function | _, [] | _, [ "" ] -> true | i, [ g ] -> (* need to find a match that matches to end of string *) find_substrings ~start_point:i g x |> List.exists (fun j -> j + String.length g = String.length x) | 0, "" :: g :: gs -> find_substrings g x |> List.exists (fun j -> contains_all_sections (j + String.length g, gs)) | i, g :: gs -> find_substrings ~start_point:i g x |> List.exists (fun j -> (if i = 0 then j = 0 else true) && contains_all_sections (j + String.length g, gs)) in contains_all_sections (0, split '*' glob) let matches_globs ~globs x = List.exists (fun glob -> matches_glob ~glob x) globs let filter_files ~globs files = List.filter (matches_globs ~globs) files
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>