ma3266
ma3266

Reputation: 59

KDB projection with multiple variables

I have a function on KDB server as test[date;sym;starttime;endtime] and I want to run this function for list of symbol with specific date, starttime and endtime. for eg Test[2014.07.02,IBM,09:30:00,"11:00:25.325"] is one such row of the list which i want to pass to the "Test" function. I understand the projection function in KDB for eg each right/left (x f/: y) but how to pass a list of specific values for all the input arguments. Please see below for the input list

  Date     Symbol   Starttime   Endtime

2014.07.02  IBM     09:30:45    15:59:59.2

2014.07.03  AAPL    09:40:50    13:52:19.125

I will appreciate any help in this regard.

Thanks,

Upvotes: 2

Views: 1851

Answers (1)

Rahul
Rahul

Reputation: 3969

Here is my understanding of your doubt:

You have a list of inputs as L:(inputs1;inputs2;...) , where inputs1 is a list of (date;symbol;starttime;endtime) and you want to apply 'test' function on each input list in 'L'.

For this, KDB provide 'dot' operator.

Ex:

    q) f:{[a;b;c]  a+b+c}
    q) f . (1 2 3)
    q) 6

For list of inputs:

    q) f ./: ((1 2 3);(4 5 6))
    q) 6  15

In your case, it would be like:

    q)test ./:L

Reference: https://code.kx.com/q/ref/apply/

Upvotes: 2

Related Questions