kdb+ - What type of composition is (count 1 2 3,) - Stack Overflow

I understand (count 1 2 3,) is a composition, because I see its type is 105.q)type(count 5 6,)105hIni

I understand (count 1 2 3,) is a composition, because I see its type is 105.

q)type(count 5 6,)
105h

Initially I thought this is an example of implicit composition, which

Compose one or more unary values with a higher-rank value

I thought the values are

  1. unary: count
  2. unary: 1 2 3
  3. binary: , (join)

However, I don't think that's correct because , (join operator) has rank 2, but the result of the composition only has rank 1. This goes against what I read, i.e. result of composition should have the same rank as the last value.

Could someone help explain how exactly this composition works?

I suspect the "composed values" are instead

  1. unary: count
  2. unary: 1 2 3,

If this is the case, doesn't composing a series of unary values require an @ (apply at) as stated at the bottom of this page?

I understand (count 1 2 3,) is a composition, because I see its type is 105.

q)type(count 5 6,)
105h

Initially I thought this is an example of implicit composition, which

Compose one or more unary values with a higher-rank value

I thought the values are

  1. unary: count
  2. unary: 1 2 3
  3. binary: , (join)

However, I don't think that's correct because , (join operator) has rank 2, but the result of the composition only has rank 1. This goes against what I read, i.e. result of composition should have the same rank as the last value.

Could someone help explain how exactly this composition works?

I suspect the "composed values" are instead

  1. unary: count
  2. unary: 1 2 3,

If this is the case, doesn't composing a series of unary values require an @ (apply at) as stated at the bottom of this page?

Share Improve this question asked Nov 29, 2024 at 4:10 kgf3JfUtWkgf3JfUtW 14.9k12 gold badges62 silver badges89 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

It is implicit composition but is created in a different order giving a different outcome.

The example from the site:

  • 0|+ is noun rank2 rank2

This example binds the noun to the rank2 to it's right leaving the trailing rank2 giving the rank of the whole composition as 2.

Your example:

  • count 5 6, is rank1 noun rank2

This example again binds the noun to rank2 to it's right which drops it to rank 1 before composing

  • https://code.kx.com/q/basics/syntax/#prefix-infix-postfix
  • https://code.kx.com/q/basics/syntax/#nouns

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1736214068a3870116.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信