push_element/2 - efficient sliding window
Ulf Wiger (AL/EAB)
Wed Aug 10 16:49:38 CEST 2005
Hmmm, I think I'll let someone else take care of that one. (:
I think tuples of 1,000,000 items are a bit ... impractical in
> -----Original Message-----
> [mailto:]On Behalf Of Joel Reymont
> Sent: den 10 augusti 2005 16:46
> To: Erlang Users' List
> Subject: Re: push_element/2 - efficient sliding window
> Go Uffe!
> Now I just need another BIF to slide a tuple of a fixed size over a
> large tuple. Then I would be happy :-). Say you have a tuple of
> 1,000,000 items and I want to move a window of 100 items through it,
> shifting it from 1 to 100 then from 2 to 101 and so on.
> For extra credit it should not copy data but return a "reference"
> which would indeed make it a "window".
> On Aug 10, 2005, at 4:23 PM, Ulf Wiger (AL/EAB) wrote:
> > erlang:push_element(Tuple, Value) pushes value into position 1 of
> > Tuple, shifting the existing values one step to the right.
> This can
> > be used as a fixed-size sliding window which costs the same as
> > setelement/3 to update.
More information about the erlang-questions