Thanks for the article. I'd agree that I have to check the docs every time for these kind of methods. I agree that drop & take methods more usable.
I'm curious though, as you understand these data structures very well, if you do want to take a middle slice is there any performance penalty in doing two steps instead of one? I guess there must be but perhaps is minor? I'm not sure I can remember a case where I needed to take a middle slice but as I said, just curious.
Fun fact: Both in 0.18 and the upcomming 0.19, slice is actually implemented internally as array |> sliceLeft from |> sliceRight to.
So no, no performance change. In fact, since drop and take wouldn't need to convert negative indices to positive indices, it would likely result in a minor performance boost.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the article. I'd agree that I have to check the docs every time for these kind of methods. I agree that drop & take methods more usable.
I'm curious though, as you understand these data structures very well, if you do want to take a middle slice is there any performance penalty in doing two steps instead of one? I guess there must be but perhaps is minor? I'm not sure I can remember a case where I needed to take a middle slice but as I said, just curious.
Fun fact: Both in 0.18 and the upcomming 0.19,
slice
is actually implemented internally asarray |> sliceLeft from |> sliceRight to
.So no, no performance change. In fact, since
drop
andtake
wouldn't need to convert negative indices to positive indices, it would likely result in a minor performance boost.