mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-18 09:39:47 +00:00
Add some docs to matchesAtHelp
This commit is contained in:
parent
1d7dc65800
commit
c9c2f61e3e
1 changed files with 5 additions and 1 deletions
|
@ -452,11 +452,15 @@ matchesAt = \haystack, haystackIndex, needle ->
|
||||||
matchesAtHelp : Str, Nat, Str, Nat, Nat, Nat -> Bool
|
matchesAtHelp : Str, Nat, Str, Nat, Nat, Nat -> Bool
|
||||||
matchesAtHelp = \haystack, haystackIndex, needle, needleIndex, needleLength, endIndex ->
|
matchesAtHelp = \haystack, haystackIndex, needle, needleIndex, needleLength, endIndex ->
|
||||||
if haystackIndex < endIndex then
|
if haystackIndex < endIndex then
|
||||||
if Str.getUnsafe haystack haystackIndex == Str.getUnsafe needle needleIndex then
|
nextNeedleCharMatches =
|
||||||
|
Str.getUnsafe haystack haystackIndex == Str.getUnsafe needle needleIndex
|
||||||
|
if nextNeedleCharMatches then
|
||||||
matchesAtHelp haystack (haystackIndex + 1) needle (needleIndex + 1) needleLength endIndex
|
matchesAtHelp haystack (haystackIndex + 1) needle (needleIndex + 1) needleLength endIndex
|
||||||
else
|
else
|
||||||
Bool.false
|
Bool.false
|
||||||
else
|
else
|
||||||
|
# If we're at the end of the haystack, the needle was matched only if
|
||||||
|
# we've walked the entire needle as well.
|
||||||
needleIndex == needleLength
|
needleIndex == needleLength
|
||||||
|
|
||||||
## Walks over the string's UTF-8 bytes, calling a function which updates a state using each
|
## Walks over the string's UTF-8 bytes, calling a function which updates a state using each
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue