Skip to content

Instantly share code, notes, and snippets.

@quangnle
Last active March 9, 2016 03:46
Show Gist options
  • Save quangnle/68735d8fa0bafcd10c64 to your computer and use it in GitHub Desktop.
Save quangnle/68735d8fa0bafcd10c64 to your computer and use it in GitHub Desktop.
masked matching direct recursive
let rec directmatch (s:string) (d:string) (i:int) (j:int) (prev:int) =
if i = s.Length then true
else
if s.[i] = '*' then directmatch s d (i + 1) j i
else
if j < d.Length then
if s.[i] = d.[j] then directmatch s d (i + 1) (j + 1) prev
else directmatch s d (prev + 1) (j - i + prev + 2) prev
else false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment