Can someone make sense of this line:
t@:where `g=attr each t@\:`sym;
Perhaps typing it out in “english”.
In particular, what do “@:” and “@:”
Can someone make sense of this line:
t@:where `g=attr each t@\:`sym;
Perhaps typing it out in “english”.
In particular, what do “@:” and “@:”
q)t:trade q)t @ sym // Get items sym from t // using each left (\:) q)t:tradequote q)t @\: sym // Get items sym from each item of t .. q)where g=attr each t@:sym // returns indexes of true statement (1b) 0 1 // https://code.kx.com/q/ref/amend/ q)t@:where g=attr each t@:sym // ammends the list t at index 0 1 q)t trade`quote
The @ in t@\: and in t@: where is Index At. t is a symbol vector that names tables. In the former expression t is interpreted as references to the tables it names; in the latter, simply as a vector of symbols.
In t@\:(Index At Each Left) the right argument is a symbol. The left argument t is a symbol vector that is also a list of names of tables. Index At is applied to each table, returning a list of sym columns.
In t@: (Index At Assign) the colon denotes assigning through an operator: equivalent to t:t@where. (Index At can often be elided, so it could also be written here t:t where.) The right argument the result of where is longs, and Index At uses it to index vector t, ignoring the tables it names.