I need to make extensive use of:
slice :: Int -> Int -> ByteString -> ByteString
slice start len = take len . drop start
Two part question:
(Int, Int) -> ByteString -> ByteString
and some flip
'd versions of same. I also tried looking for [a]
versions to see if there was a name in common use.I'm suspicious that I'm doing something wrong because I strongly expected to find lots of people having gone down the same road, but my google-fu isn't finding anything.
The idiomatic way is via take
and drop
, which has O(1) complexity on strict bytestrings.
slice
is not provided, to discourage the reliance on unsafe indexing operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With