如何手动构造以下功能语句
How to manually construct the following functional statement
我需要为以下表达式创建一个函数语句
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
()
接下来,让我们使用 enlist,
技巧在您的 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"
HTH,肖恩
我需要为以下表达式创建一个函数语句
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
()
接下来,让我们使用 enlist,
技巧在您的 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"
HTH,肖恩