Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kdb 如何手动构造以下函数语句_Kdb - Fatal编程技术网

Kdb 如何手动构造以下函数语句

Kdb 如何手动构造以下函数语句,kdb,Kdb,我需要为下面的表达式创建一个函数语句 select from table where not any venue like/:("tst1";tst2) 这就是我现在拥有的: (enlist(~:;(any;((/:;like);`venue;(enlist;a))))) 其中a可以是tst1或tst1;tst2 这就是问题所在。我想将a作为参数传递,但它不起作用。 这条线应该是这样的: (enlist(~:;(any;((/:;like);`venue;(enlist;"tst1";"ts

我需要为下面的表达式创建一个函数语句

select from table where not any venue like/:("tst1";tst2)
这就是我现在拥有的:

(enlist(~:;(any;((/:;like);`venue;(enlist;a)))))
其中a可以是tst1或tst1;tst2

这就是问题所在。我想将a作为参数传递,但它不起作用。 这条线应该是这样的:

(enlist(~:;(any;((/:;like);`venue;(enlist;"tst1";"tst2")))))
任何人都有任何建议。我有点卡住了。

首先让我们使用parse来查看树:

q)parse "select from table where not any venue like/:(\"tst1\";\"tst2\")"
?
`table
,,(~:;(max$["b"];((/:;like);`venue;(enlist;"tst1";"tst2"))))
0b
()
接下来,让我们使用登记技巧在like语句中构建元素列表

q)0N!enlist,`a`b;
(enlist;`a;`b)

// let's define 'a' and use the same method
q)a:("tst1";"tst2")
q)enlist,a
enlist
"tst1"
"tst2"
q)0N!enlist,a;
(enlist;"tst1";"tst2")
让我们把它拼凑起来

// define table
q)table:([]venue:("tst1";"tst2";"tst3"))
q)?[`table;enlist(not;(any;((/:;like);`venue;enlist,a)));0b;()]
venue
------
"tst3"
请注意,您没有使用任何类型的正则表达式,因此最好使用直接匹配:

q)select from table where not ([]venue) in ([]venue:a)
venue
------
"tst3"

// or a function to help you
q)f:{[lst] select from table where not ([]venue) in ([]venue:lst)}
q)f[a]
venue
------
"tst3"
嗯,肖恩

首先让我们使用parse来查看树:

q)parse "select from table where not any venue like/:(\"tst1\";\"tst2\")"
?
`table
,,(~:;(max$["b"];((/:;like);`venue;(enlist;"tst1";"tst2"))))
0b
()
接下来,让我们使用登记技巧在like语句中构建元素列表

q)0N!enlist,`a`b;
(enlist;`a;`b)

// let's define 'a' and use the same method
q)a:("tst1";"tst2")
q)enlist,a
enlist
"tst1"
"tst2"
q)0N!enlist,a;
(enlist;"tst1";"tst2")
让我们把它拼凑起来

// define table
q)table:([]venue:("tst1";"tst2";"tst3"))
q)?[`table;enlist(not;(any;((/:;like);`venue;enlist,a)));0b;()]
venue
------
"tst3"
请注意,您没有使用任何类型的正则表达式,因此最好使用直接匹配:

q)select from table where not ([]venue) in ([]venue:a)
venue
------
"tst3"

// or a function to help you
q)f:{[lst] select from table where not ([]venue) in ([]venue:lst)}
q)f[a]
venue
------
"tst3"
嗨,肖恩。请解释一下这个登记,a。这是怎么回事。这是我第一次看到它,是的,你的解决方案是有效的。所以我所要做的就是创建一个列表,其中一个元素是登记。哇!Thanksenlist,就是简单地将一个函数与另一个变量连接起来。你也可以用{x*x},a做同样的事情。需要将它们连接起来以创建给定的解析树结构。至于为什么需要登记,这是由于如何处理/:即解析sym foo/:x;Y志。请解释一下这个登记,a。这是怎么回事。这是我第一次看到它,是的,你的解决方案是有效的。所以我所要做的就是创建一个列表,其中一个元素是登记。哇!Thanksenlist,就是简单地将一个函数与另一个变量连接起来。你也可以用{x*x},a做同样的事情。需要将它们连接起来以创建给定的解析树结构。至于为什么需要登记,这是由于如何处理/:即解析sym foo/:x;YZ