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,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`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue