2

On a page https://shakti.com/tutorial/ I've found the solution, it is

#:'z / counts each list

The same solution was mentioned in https://code.kx.com/v2/learn/startingkdb/language/ by switching to k mode in q:

q) #:'(1 2;"abc")            / equivalent k expression
2 3

Why this expression #:' counts the number?

  • # counts
  • ' is an each Adverb
  • but what : means in this case? This is not an assignment, right?
4

1 回答 1

1

在页面http://www.math.bas.bg/bantchev/place/k.html他们提到:

:within|:用于强制将动词|解释为 monad,因为默认情况下歧义被解决,有利于 dyads

同样在这里http://web.archive.org/web/20050504070651/http://www.kx.com/technical/documents/kreflite.pdf注意到同样的事情:

请注意,每当将 Each 应用于原始动词的单子时,例如在!:'Enumerate-Each 中,必须通过用冒号修改动词来明确单子格。如果不存在修饰符,则假定二元情况。

这是有道理的:

/ # want's to act as dyadic verb
  #' (1 2; "abc")
#'[(1 2;"abc")]

/ make use of dyadic # behavior
  5 6 #' (1 2; "abc")
(1 2 1 2 1;"abcabc")

/ monadic case
  #:' (1 2; "abc")
2 3
于 2019-11-15T11:31:30.210 回答