Proposal: Add insertAt to Data.Sequence
David Feuer
david.feuer at gmail.com
Sun May 29 20:32:46 UTC 2016
I've come up with an implementation of
insertAt :: Int -> a -> Seq a -> Seq a
-- Defined to be equivalent to
insertAt i x xs
| i < 0 || i > length xs = error "insertAt: index out of range"
| otherwise = take i xs <> singleton x <> drop i xs
that inserts the given element at the given index with very little
tree restructuring. I came up with the vague notion that it might be
interesting to try to do something like this early last year, but I
wasn't sure how at the time. I largely forgot about it until today,
when someone on StackOverflow pointed to the issue I'd opened and
asked if it would be implemented, presumably because he wants it. What
do y'all think?
David Feuer
More information about the Libraries
mailing list