[Haskell] Looking for a random-access sequence data structure
ross at soi.city.ac.uk
Fri Jan 13 15:52:52 EST 2006
On Fri, Jan 13, 2006 at 08:25:46PM +0000, Duncan Coutts wrote:
> On Fri, 2006-01-13 at 13:53 +0000, Ross Paterson wrote:
> > Have a look at Data.Sequence (in CVS/darcs version), docs at
> > http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-Sequence.html
> It's probably too much to ask, but here's a question:
> would it be possible to provide an operation that gives a left or right
> view from looking up an index. Say:
> viewrFromIndex :: Seq a -> Int -> ViewL a
> viewlFromIndex :: Seq a -> Int -> ViewR a
> The library currently provides views for the each end of the sequence.
> viewl :: Seq a -> ViewL a
> viewr :: Seq a -> ViewR a
> I suppose this would be a zipper-like iterator for the sequence?
I'm not entirely sure what these are intended to do, but can't you
just compose view[lr] with take/drop?
A zipper for a non-empty sequence is just an element and a pair of
sequences. Moving it by k positions using splitAt and (><) costs
More information about the Haskell