从q中的表调用函数及其参数

kev*_*ntu 0 kdb

我试图从表中调用一个函数及其参数.所以我通过以下方式调用函数:

(first exec function from table where id=jobId)
Run Code Online (Sandbox Code Playgroud)

在这个例子中,我得到:+

然后我把这些论点称为:

[first exec args from table where id=jobId]
Run Code Online (Sandbox Code Playgroud)

我得到一个例子[2 2]

将两条线相继运行为:

`(first exec func from table where id=jobId)[first exec args from .table where id=jobId]`
Run Code Online (Sandbox Code Playgroud)

会给我:+ [2 2]

但我需要:+ [2; 2].

我正在从文件中读到这个陈述,但我无法完全实现.

"exec函数形式的参数(?[;;;])必须以解析的形式传递,并根据所需的结果传递给特定的数据结构."

我试图将参数部分的传递转换为这样的函数调用:

?[table;jobId=id;args;()]

ter*_*nch 5

要涵盖单输入,多输入等功能的一般情况,您需要以下内容:

q)t:([]func:({x+1};floor;{x+y};first;{x+100});args:(12;1.5;2 2;"abc";`foo))

q)t
func    args
-------------
{x+1}   12
_:      1.5
{x+y}   2 2
*:      "abc"
{x+100} `foo

q)update res:{.[x;(),y;@[x;y;]`$]}'[func;args] from t
func    args  res
-------------------
{x+1}   12    13
_:      1.5   1
{x+y}   2 2   4
*:      "abc" "a"
{x+100} `foo  `type
Run Code Online (Sandbox Code Playgroud)