I’m puzzled by the behavior of “wj”. Here’s my experiement:q) t:( time: 10:00:03 10:00:04 10:00:05)q) t1:( time: 10:00:01 10:00:03 10:00:03 10:00:04 10:00:08; b: 1 10100 1000 10000)q) w: ( t.time; t.time )q) wj[w;time;t;(t1;(::;
b))] / here’s where I use "wj"time b-------------10:00:03 10010:00:04 100010:00:05 1000That’s not what I would expect to be the result of the wj call. Iwould expect this output:time b----------------10:00:03 10 100 <– note: two matched the interval10:00:04 ,100010:00:05 int$() \<-- note: none match the intervalHave I got the wrong idea about "wj", or am i doing something silly,or is there a bug?I can get what I want like this:q) t lj (
time xgroup t1)But that’s not efficient at all. Not like wj.So I’m a bit stuck. I need wj to work the way I imagined :-) or findsomething as efficient as “wj” which does work the way I’m imagining.–Mike
wj is generalization of aj
so it is asof (uses bin)
you might do
{exec b from t1 where time=x}each t.time
?Attila
I’ve staring at “wj” for a while, trying to figure out how it did it’swork. Based on those observations I’ve written up own variation whichdoes what I want. For what it is worth, I include the key bit of codebelow:/----------------------------------------------------------------------------/ calcIndexCuts/ calculates the index pairs which slice “vec” into “ranges” ofvalues./ “vec” is a sorted vector/ “ranges” is (lowerValues;upperValues) which define ranges of valuesin/ “vec” for which we want indexes (pairs). Ranges are inclusive ofbookend values./ Returns (lowerIndexes; upperIndexes) which slice “vec” into thenominated/ ranges of values./ NOTE: “vec” may contain duplicates/ NOTE: if a range is not present in vec, then the associated lowerindex will be -1calcIndexCuts: {[vec; ranges] lowerI: vec bin (ranges[0]-1); lowerI: (lowerI+1) and ((count vec) - 1); / “and” is minimum upperI: vec bin ranges[1]; noMatchingValues: (lowerI <= upperI) and (vec[lowerI] < ranges[0]); lowerI[where noMatchingValues] : -1; (lowerI; upperI) }So much effort, for so few lines! I hope this may help someone,sometime. Perhaps.On Jun 14, 7:35?pm, Mike Thompson <mike.thompsona…> wrote:> I’m puzzled by the behavior of “wj”. ? Here’s my experiement:>> q) t:( ?time: 10:00:03 10:00:04 10:00:05)> q) t1:( time: 10:00:01 10:00:03 10:00:03 10:00:04 10:00:08; ?b: 1 10> 100 1000 10000)> q) w: ( t.time; t.time )> q) wj[w;time;t;(t1;(::;
b))] ? ? ? / ?here’s where I use “wj”> time ? ? b> -------------> 10:00:03 100> 10:00:04 1000> 10:00:05 1000>> That’s not what I would expect to be the result of the wj call. ? I> would expect this output:>> time ? ? b> ----------------> 10:00:03 10 100 ? ? ? ? ?<– note: ?two matched the interval> 10:00:04 ,1000> 10:00:05 int$() ? ? ? ? ? <-- note: none match the interval>> Have I got the wrong idea about "wj", or am i doing something silly,> or is there a bug?>> I can get what I want like this:>> q) t lj (
time xgroup t1)>> But that’s not efficient at all. ?Not like wj.>> So I’m a bit stuck. ?I need wj to work the way I imagined :-) ?or find> something as efficient as “wj” which does work the way I’m imagining.>> –> Mike</mike.thompsona…>