mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
List.sublist: make sure input list is decremented if slice length is 0
This commit is contained in:
parent
eadc4a41ff
commit
32207beedf
1 changed files with 5 additions and 1 deletions
|
@ -820,7 +820,11 @@ findIndex = \list, matcher ->
|
||||||
## Some languages have a function called **`slice`** which works similarly to this.
|
## Some languages have a function called **`slice`** which works similarly to this.
|
||||||
sublist : List elem, { start : Nat, len : Nat } -> List elem
|
sublist : List elem, { start : Nat, len : Nat } -> List elem
|
||||||
sublist = \list, config ->
|
sublist = \list, config ->
|
||||||
sublistLowlevel list config.start config.len
|
if config.len == 0 then
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
sublistLowlevel list config.start config.len
|
||||||
|
|
||||||
|
|
||||||
sublistLowlevel : List elem, Nat, Nat -> List elem
|
sublistLowlevel : List elem, Nat, Nat -> List elem
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue