Proposal: Export cycleN from Data.Sequence
Joachim Breitner
mail at joachim-breitner.de
Tue Apr 26 08:29:19 UTC 2016
Hi,
I consent, and have no advice to offer :-)
Greetings,
Joachim
Am Montag, den 25.04.2016, 23:50 -0400 schrieb David Feuer:
> It's been quite a while, and I've had a single +1 on this with very
> little comment. Does anyone else have an opinion? Is anyone opposed?
> Does anyone think `cycleN n` should produce a *result* of length `n`
> instead of cycling `n` times? I seek advice and consent of anyone who
> cares.
>
> On Wed, Mar 11, 2015 at 11:14 AM, David Feuer <david.feuer at gmail.com>
> wrote:
> >
> > Yesterday I rewrote `*>` for Data.Sequence (again), using an
> > internal function
> >
> > cycleN :: Int -> Seq a -> Seq a
> >
> > The name of the function is based on that of
> > Data.Sequence.iterateN.
> > cycleN takes a sequence and cycles it as many times as requested:
> >
> > cycleN 0 $ fromList [1,2] = []
> > cycleN 5 $ fromList [1,2] = [1,2,1,2,1,2,1,2,1,2]
> >
> > The function is written to maximize sharing in the result sequence
> > and
> > to minimize construction time. Specifically, cycleN n xs should
> > take
> > something like O(|xs| + log n) space (of which all but O(log |xs| +
> > log n) is shared with the structure of xs) and O(log |xs| + log n)
> > time.
> >
> > With current (on GitHub) Data.Sequence exports, the only way to get
> > this functionality with these time and space bounds is to combine
> > replicate with *> :
> >
> > cycleN n xs = replicate n () *> xs
> >
> > This strikes me as a bit unpleasant.
> >
> > David
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
--
Joachim “nomeata” Breitner
mail at joachim-breitner.de • https://www.joachim-breitner.de/
XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160426/10827441/attachment-0001.sig>
More information about the Libraries
mailing list