This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
20
unikernel/duniverse/astring/test/total.ml
Normal file
20
unikernel/duniverse/astring/test/total.ml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
open Astring
|
||||
|
||||
(* Total *)
|
||||
let find_all p s =
|
||||
let rec loop acc i = match String.find ~start:i p s with
|
||||
| None -> List.rev acc
|
||||
| Some i -> loop (i :: acc) (i + 1)
|
||||
in
|
||||
loop [] 0
|
||||
|
||||
(* Not total *)
|
||||
let find_all p s =
|
||||
let rec loop acc i =
|
||||
if i > String.length s then List.rev acc else
|
||||
match String.find ~start:i p s with
|
||||
| None -> List.rev acc
|
||||
| Some i -> loop (i :: acc) (i + 1)
|
||||
in
|
||||
loop [] 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue