Re: [haskell-art] purely functional circular buffers

2011-02-19 Thread Sebastian Fischer
On Sat, Feb 19, 2011 at 9:00 PM, John Lato wrote: > On Sat, Feb 19, 2011 at 9:14 AM, Sebastian Fischer wrote: > >> Instead of shifting all elements through the buffer you could store an >> index to the oldest element and increase it (modulo size) when >> overwriting. >> > This was the first thing

Re: [haskell-art] purely functional circular buffers

2011-02-19 Thread John Lato
On Sat, Feb 19, 2011 at 9:14 AM, Sebastian Fischer wrote: > On Sat, Feb 19, 2011 at 2:05 AM, John Lato wrote: > >> On Fri, Feb 18, 2011 at 1:14 AM, Sebastian Fischer wrote: >> >>> Maybe one of the simpler structures presented there (like random access >>> lists) provides faster indexing. >>> >> >

Re: [haskell-art] purely functional circular buffers

2011-02-19 Thread Sebastian Fischer
On Sat, Feb 19, 2011 at 2:05 AM, John Lato wrote: > On Fri, Feb 18, 2011 at 1:14 AM, Sebastian Fischer wrote: > >> Maybe one of the simpler structures presented there (like random access >> lists) provides faster indexing. >> > > I believe the difficulty with random access lists is in dropping re

Re: [haskell-art] purely functional circular buffers

2011-02-18 Thread John Lato
On Fri, Feb 18, 2011 at 1:14 AM, Sebastian Fischer wrote: > So far the best I've found is Data.Sequence.Seq, which in my tests >> outperforms mutable vectors, but only for reads from the head or tail of the >> sequence. Indexing into the middle of the sequence is relatively slow. >> > > Data.Sequ

Re: [haskell-art] purely functional circular buffers

2011-02-17 Thread Sebastian Fischer
> > So far the best I've found is Data.Sequence.Seq, which in my tests > outperforms mutable vectors, but only for reads from the head or tail of the > sequence. Indexing into the middle of the sequence is relatively slow. > Data.Sequence is implemented as a finger tree which is the culmination p

Re: [haskell-art] purely functional circular buffers

2011-02-17 Thread Stephen Tetley
On 17 February 2011 19:48, Stephen Sinclair wrote: [SNIP] > However, there is this common pattern in media- or simulation-oriented > programs (like games too): > > 1. Initialize state. > 2. Update state based on initial state. > 3. Update state based on state 2. > 4. Update state based on state 3.

Re: [haskell-art] purely functional circular buffers

2011-02-17 Thread Stephen Sinclair
On Thu, Feb 17, 2011 at 7:27 AM, John Lato wrote: > Does anyone know of a purely functional equivalent to a circular buffer? >  I'm looking for something that supports efficient insertion and lookup, and > doesn't rely upon mutable data.  I don't want to use mutable data because > I'd like to embe

Re: [haskell-art] purely functional circular buffers

2011-02-17 Thread John Lato
On Thu, Feb 17, 2011 at 6:21 PM, Henning Thielemann < lemm...@henning-thielemann.de> wrote: > John Lato schrieb: > > > Does anyone know of a purely functional equivalent to a circular buffer? > > It depends on the application you have in mind. > For programming a constant delay of n samples of a l

Re: [haskell-art] purely functional circular buffers

2011-02-17 Thread Henning Thielemann
John Lato schrieb: > Does anyone know of a purely functional equivalent to a circular buffer? It depends on the application you have in mind. For programming a constant delay of n samples of a lazy list including feedback, you can use a lazy list instead of a circular buffer. For efficiency reaso

[haskell-art] purely functional circular buffers

2011-02-17 Thread John Lato
Does anyone know of a purely functional equivalent to a circular buffer? I'm looking for something that supports efficient insertion and lookup, and doesn't rely upon mutable data. I don't want to use mutable data because I'd like to embed this in CCA, which to my knowledge doesn't yet support Kl