Greetings,
I am very new to q (kdb+), I have got the book and started reading it yesterday. As I read I try to do some work on the way. I have faced a problem and cannot seem to find the solution in the book just yet.
I have a table:
ticket px vol
c 3 3
a 2 8
a 9 3
a 2 1
a 1 6
b 8 8
c 4 6
b 4 7
c 7 8
a 9 1
I need to find when each ticket shows up for the first time in the table. So I do the following
q)aMinIdx: (select ticket from t)?`a
q)bMinIdx: (select ticket from t)?`b
q)cMinIdx: (select ticket from t)?`c
q)aMinIdx
1
q)bMinIdx
5
q)cMinIdx
0
Now, I would very much like to write down these results (i.e aMinIdx, bMinIdx and cMinIdx) into a table for the future reference. So I construct a new table, but I get an error and I do not understand why.
firstTimeTksIdx:( ticket: a
b`c; Indx: aMinIdx bMinIdx cMinIdx)
': Bad file descriptor
Interestingly, if I simply substitute aMinId and the rest for just integers, then it works find. It looks like it doesn’t allow me to use variable names aMinIdx, bMinIdx, cMinIdx. I have checked their type
)type aMinIdx
-7h
seems to be a standard 64bit long atom (all three variables. I can do:
aMinIdx + 1
2
So I am a bit baffled why I can’t use those when constructing a table. I tried using function “value” in all possible combinations, but it doesn’t seem to help.
Please, if someone could point out the problem, I would be very glad and very thankful.
Regards, V.A.