Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,6 @@
let match1 s1 s2 =
let len1 = String.length s1
and len2 = String.length s2 in
if len1 < len2 then false else
let sub = String.sub s1 0 len2 in
(sub = s2)

View file

@ -0,0 +1,10 @@
let match2 s1 s2 =
let len1 = String.length s1
and len2 = String.length s2 in
if len1 < len2 then false else
let rec aux i =
if i < 0 then false else
let sub = String.sub s1 i len2 in
if (sub = s2) then true else aux (pred i)
in
aux (len1 - len2)

View file

@ -0,0 +1,6 @@
let match3 s1 s2 =
let len1 = String.length s1
and len2 = String.length s2 in
if len1 < len2 then false else
let sub = String.sub s1 (len1 - len2) len2 in
(sub = s2)

View file

@ -0,0 +1,10 @@
let match2_loc s1 s2 =
let len1 = String.length s1
and len2 = String.length s2 in
if len1 < len2 then (false, -1) else
let rec aux i =
if i < 0 then (false, -1) else
let sub = String.sub s1 i len2 in
if (sub = s2) then (true, i) else aux (pred i)
in
aux (len1 - len2)

View file

@ -0,0 +1,12 @@
let match2_num s1 s2 =
let len1 = String.length s1
and len2 = String.length s2 in
if len1 < len2 then (false, 0) else
let rec aux i n =
if i < 0 then (n <> 0, n) else
let sub = String.sub s1 i len2 in
if (sub = s2)
then aux (pred i) (succ n)
else aux (pred i) (n)
in
aux (len1 - len2) 0