4 ms·
import Control.Lens.Cons case uncons v of Nothing -> .. empty vector .. Just (head, tail) -> ..
by Peaker 10y ago
import Control.Lens.Cons
case uncons v of
Nothing -> .. empty vector ..
Just (head, tail) -> ..
- junke 10y agoInteresting, thanks. I am right that this will extract consecutive views of the original array as pairs of (item, slice) elements? I guess array elements need not be copied, but there will still be a slight memory overhead, right? or is it some "zero-cost" abstraction? I am not trying to attack the code for efficiency, just curious about what current implementations can make from this.
- Peaker 10y agoIt shouldn't copy anything - I'd expect it to be optimized to not allocate any memory at all.