1

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.

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Fomalhaut -C
  • 320
  • 2
  • 13
  • It may help if you could provide an example - it doesn't necessarily have to be the exact function you're using, but something which returns a similar output allows people to replicate and understand your problem much better – Jonathon McMurray Jan 24 '18 at 20:38

1 Answers1

2

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
Alexander Belopolsky
  • 2,228
  • 10
  • 26
  • Unfortunately I get a wrong type error using this method. Please note that the function outputs a row*column table for each argument passed, if that makes a difference. – Fomalhaut -C Jan 24 '18 at 19:12
  • 1
    Can you share an example of a function for which this method fails? I am not sure what you describe as "a row*column table". – Alexander Belopolsky Jan 24 '18 at 19:29
  • This function is proprietary (my company created an internal API we use and this function is part of it). Loosely: `(('$"username:password") ('functionName ; [x] ; date ; date ; ('paramKeys)!(paramVals)))` and what I mean is that the function returns a table that is, say, 10 columns wide * 1000000 rows long. I need to generate many tables like that and concatenate them. – Fomalhaut -C Jan 24 '18 at 19:45
  • Sorry, but I don't understand what you wrote. Even if I replace single quote marks with backticks, the code you displayed is not valid q. Maybe you can amend your question with more details? The SO editor for questions is somewhat more capable than the one for comments. You should be able to use backticks freely in the indented code displays. – Alexander Belopolsky Jan 24 '18 at 19:52