September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,18 @@
class HistoryVar{
var [private] _v, _history=List(), maxSz;
fcn init(v,maxEntries=3){ maxSz=maxEntries; set(v) }
fcn set(v){
_v=v; _history.append(T(Time.Clock.time,v));
if(_history.len()>maxSz) _history.del(0);
self
}
fcn get(n=0){ // look back into history
z:=_history.len();
n=(if(n>=z) 0 else z-n-1);
_history[n][1]
}
var [proxy] v=fcn{ _v };
var [proxy] history=
fcn{ _history.pump(List,fcn([(t,v)]){ T(Time.Date.ctime(t),v) }) };
fcn __opAdd(x){ set(_v + x); self }
}

View file

@ -0,0 +1,6 @@
hv:=HistoryVar(123);
hv+4;
hv.set("Shuttle prepared for liftoff");
hv+": orbit achived";
hv.history.concat("\n").println();
hv.get(3).println("<-- value two changes ago");