Fomalhaut -C
Fomalhaut -C

Reputation: 320

How to apply function that returns table to a list? (Q+KDB)

I have a function {[x]} that returns a table of time series values. I would like to apply this to different keys `a`b`c but am unable to do so using {[x]}/`a`b`c

I'd like the result to be one table with the contents of each individual query. How can I go about doing this? FWIW, I have to do this in Q - can't install q for python etc.

Upvotes: 1

Views: 678

Answers (1)

Alexander Belopolsky
Alexander Belopolsky

Reputation: 2268

Let your function be

q)f:{([]t:00:01 00:02;x)}
q)f `a
t     x
-------
00:01 a
00:02 a

You can apply it to a list and flatten the result as folows

q)raze f each `a`b
t     x
-------
00:01 a
00:02 a
00:01 b
00:02 b

Upvotes: 2

Related Questions