kdb:在变量列表上调用parse [英] kdb: calling parse on a list of variables

查看:73
本文介绍了kdb:在变量列表上调用parse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从此处了解到

[...]在解析树中,变量用符号表示包含其名称.从而区分一个符号或一个符号列表从变量中获取该表达式是必要的.

鉴于此,为什么下面的表达式求结果为(enlist;`a;`b)而不是`a`b ?

问,因为似乎 enlist [`a;`b]〜`a`b 是真的.

  q)parse(a; b)";入伍`一个`b 

解决方案

我不认为您希望解析树将两个相同类型的值折叠成一个统一的列表,这会破坏 eval 解析树,例如

  q)a:1q)b:1q)q)eval解析(a; b)";1 1q)评估`a`b'类型[0]评估`a`b^ 

其次,(enlist;`a;`b) enlist [`a;`b] 不同,但是 value <(enlist;`a;`b)的/code>是:

  q)value [(enlist;`a;`b)]〜enlist [`a;`b]1b 

所以我想这归因于 eval value

之间的细微差别

I learned from here that

[...] in a parse tree a variable is represented by a symbol containing its name. Thus to distinguish a symbol or a list of symbols from a variable it is necessary to enlist that expression.

Given that, why does below expression evaluate to (enlist;`a;`b) instead of just `a`b?

Asking because it seems enlist[`a;`b]~`a`b is true.

q)parse"(a;b)"
enlist
`a
`b

解决方案

I don't think you would ever want a parse tree to collapse two same-type values into a single uniform list, it would break the ability to eval the parse tree, e.g

q)a:1
q)b:1
q)
q)eval parse"(a;b)"
1 1
q)eval `a`b
'type
  [0]  eval `a`b
       ^

And secondly, (enlist;`a;`b) isn't the same as enlist[`a;`b] however the value of (enlist;`a;`b) is:

q)value[(enlist;`a;`b)]~enlist[`a;`b]
1b

So I guess it comes down to the nuanced differences between eval and value

这篇关于kdb:在变量列表上调用parse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆