[javascript-dev] create a list of the last n values (or anything else)
Jean-Baptiste Thiebaut
pplato at gmail.com
Thu Aug 23 03:37:15 MDT 2007
- Previous message: [javascript-dev] Re: File Access Problem
- Next message: [javascript-dev] create a list of the last n values (or anything else)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
Here is the javascript code of a simple function that outputs a list of the last n values (specified in the argument, such as "js list 10"), every time it receives a new value.
I struggled to find a way of doing that with "zl" so I wrote this simple code.
I thought it might be useful to some, so here is the code (also attached):
var size_list = jsarguments[1];
var t = new Array(size_list);
var t_sorted = new Array(size_list);
var pos = 0;
function anything(v)
{
t[pos] = v;
for (var i = 0; i < size_list ; i++)
t_sorted[i] = t[(pos+1+i)%size_list];
pos = (pos+1)%size_list;
outlet(0,t_sorted);
}
best
Jean-Baptiste
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list
Type: application/octet-stream
Size: 274 bytes
Desc: not available
Url : http://www.cycling74.com/pipermail/javascript-dev/attachments/20070823/4e2c4a4f/list.obj
- Previous message: [javascript-dev] Re: File Access Problem
- Next message: [javascript-dev] create a list of the last n values (or anything else)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
