mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Fix endsWith off-by-one error
This commit is contained in:
parent
7cf5732001
commit
6f1932eae4
1 changed files with 3 additions and 2 deletions
|
@ -897,9 +897,10 @@ endsWith : List elem, List elem -> Bool
|
|||
endsWith = \list, suffix ->
|
||||
# TODO once we have seamless slices, verify that this wouldn't
|
||||
# have better performance with a function like List.compareSublists
|
||||
start = List.len list - len
|
||||
length = List.len suffix
|
||||
start = Num.subSaturated (List.len list) length
|
||||
|
||||
suffix == List.sublist list { start, len: List.len suffix }
|
||||
suffix == List.sublist list { start, len: length }
|
||||
|
||||
## Splits the list into two lists, around the given index.
|
||||
##
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue