Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Active-object/Zkl/active-object-1.zkl
Normal file
19
Task/Active-object/Zkl/active-object-1.zkl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class Integrator{
|
||||
// continuously integrate a function `K`, at each `interval` seconds'
|
||||
fcn init(f,interval=1e-4){
|
||||
var _interval=interval, K=Ref(f), S=Ref(0.0), run=True;
|
||||
self.launch(); // start me as a thread
|
||||
}
|
||||
fcn liftoff{ // entry point for the thread
|
||||
start:=Time.Clock.timef; // floating point seconds since Epoch
|
||||
t0,k0,s:=0,K.value(0),S.value;
|
||||
while(run){
|
||||
Atomic.sleep(_interval);
|
||||
t1,k1:=Time.Clock.timef - start, K.value(t1);
|
||||
s+=(k1 + k0)*(t1 - t0)/2.0; S.set(s);
|
||||
t0,k0=t1,k1;
|
||||
}
|
||||
}
|
||||
fcn sample { S.value }
|
||||
fcn setF(f) { K.set(f) }
|
||||
}
|
||||
7
Task/Active-object/Zkl/active-object-2.zkl
Normal file
7
Task/Active-object/Zkl/active-object-2.zkl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
ai:=Integrator(fcn(t){ ((0.0).pi*t).sin() });
|
||||
Atomic.sleep(2);
|
||||
ai.sample().println();
|
||||
|
||||
ai.setF(fcn{ 0 });
|
||||
Atomic.sleep(0.5);
|
||||
ai.sample().println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue