diff --git a/tick.q b/tick.q index 0680992..621a57a 100644 --- a/tick.q +++ b/tick.q @@ -27,22 +27,19 @@ if[not system"p";system"p 5010"] \l tick/u.q \d .u ld:{if[not type key L::`$(-10_string L),string x;.[L;();:;()]];i::j::-11!(-2;L);if[0<=type i;-2 (string L)," is a corrupt log. Truncate to length ",(string last i)," and restart";exit 1];hopen L}; -tick:{init[];if[not min(`time`sym~2#key flip value@)each t;'`timesym];@[;`sym;`g#]each t;d::.z.D;if[l::count y;L::`$":",y,"/",x,10#".";l::ld d]}; +tick:{[x:{init[];$[not min(`time`sym~2#key flip value@)each t;'`timesym;x]};y]@[;`sym;`g#]each t;d::.z.D;if[l::count y;L::`$":",y,"/",x,10#".";l::ld d]}; endofday:{end d;d+:1;if[l;hclose l;l::0(`.u.ld;d)]}; ts:{if[dtype first x;a,x;enlist[count[first x]#a],x]]]}; // Common function in both options (Batch; Real Time) if[system"t"; .z.ts:{pub'[t;value each t];@[`.;t;@[;`sym;`g#]0#];i::j;ts .z.D}; - upd:{[t;x] - if[not -16=type first first x;if[d<"d"$a:.z.P;.z.ts[]];a:"n"$a;x:$[0>type first x;a,x;(enlist(count first x)#a),x]]; - t insert x;if[l;l enlist (`upd;t;x);j+:1];}]; + upd:{{[t;x]t insert x;if[l;l enlist (`upd;t;x);j+:1];}[x]updC y}]; if[not system"t";system"t 1000"; .z.ts:{ts .z.D}; - upd:{[t;x]ts"d"$a:.z.P; - if[not -16=type first first x;a:"n"$a;x:$[0>type first x;a,x;(enlist(count first x)#a),x]]; - f:key flip value t;pub[t;$[0>type first x;enlist f!x;flip f!x]];if[l;l enlist (`upd;t;x);i+:1];}]; + upd:{{[t;x]f:key flip value t;pub[t;$[0>type first x;enlist f!x;flip f!x]];if[l;l enlist (`upd;t;x);i+:1];}[x] updC y}]; \d . .u.tick[src;.z.x 1]; diff --git a/tick/u.q b/tick/u.q index 21f42e4..aee4356 100644 --- a/tick/u.q +++ b/tick/u.q @@ -3,16 +3,16 @@ /2006.05.08 add \d .u -init:{w::t!(count t::tables`.)#()} +init:{w::(t::tables`.)!()} del:{w[x]_:w[x;;0]?y};.z.pc:{del[;x]each t}; -sel:{$[`~y;x;select from x where sym in y]} +sel:{(select from x where sym in y;x)`~y} -pub:{[t;x]{[t;x;w]if[count x:sel[x]w 1;(neg first w)(`upd;t;x)]}[t;x]each w t} +pub:{[t;x]{[t;x:sel[;w 1];w]if[count x;(neg first w)(`upd;t;x)]}[t;x]each w t} add:{$[(count w x)>i:w[x;;0]?.z.w;.[`.u.w;(x;i;1);union;y];w[x],:enlist(.z.w;y)];(x;$[99=type v:value x;sel[v]y;@[0#v;`sym;`g#]])} -sub:{if[x~`;:sub[;y]each t];if[not x in t;'x];del[x].z.w;add[x;y]} +sub:{[x:{$[not x in t,`;'x;x]};y]if[x~`;:sub[;y]each t];del[x].z.w;add[x;y]} end:{(neg union/[w[;;0]])@\:(`.u.end;x)}