September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,8 @@
|
|||
fcn SMA(P){
|
||||
fcn(n,ns,P){
|
||||
sz:=ns.append(n.toFloat()).len();
|
||||
if(P>sz) return(0.0);
|
||||
if(P<sz) ns.del(0);
|
||||
ns.sum(0.0)/P;
|
||||
}.fp1(List.createLong(P+1),P) // pre-allocate a list of length P+1
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
T(1,2,3,4,5,5,4,3,2,1).apply(SMA(3)).println();
|
||||
T(1,2,3,4,5,5,4,3,2,1).apply(SMA(5)).println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue