List.sublist: make sure input list is decremented if slice length is 0

This commit is contained in:
Folkert 2022-07-12 22:51:44 +02:00
parent eadc4a41ff
commit 32207beedf
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -820,8 +820,12 @@ findIndex = \list, matcher ->
## Some languages have a function called **`slice`** which works similarly to this.
sublist : List elem, { start : Nat, len : Nat } -> List elem
sublist = \list, config ->
if config.len == 0 then
[]
else
sublistLowlevel list config.start config.len
sublistLowlevel : List elem, Nat, Nat -> List elem
## Intersperses `sep` between the elements of `list`