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 reasons you can use a chunky StorableVector with chunk
size up to n.
This is like rolling out the circular buffer to an infinite list.
Something simple like
let output :: [Double]
output = mix (input + delay n output)
would work.
> 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 Kleisli arrows.
Embedding the above idea into an arrow that emits one output sample per
input sample would not work. Mutable arrays in the ST monad would help,
but this requires that the arrow is built around the ST monad.
_______________________________________________
haskell-art mailing list
[email protected]
http://lists.lurk.org/mailman/listinfo/haskell-art