kgf3JfUtW
kgf3JfUtW

Reputation: 14918

kdb: can the $ function take 5 arguments?

From https://code.kx.com/q/wp/parse-trees/#the-solution

I came across below function, which translates enlisted symbols or symbol lists into the string "enlist".

ereptest:{ //returns a boolean
  (1=count x) and ((0=type x) and 11=type first x) or 11=type x}
ereplace:{"enlist",.Q.s1 first x}
funcEn:{$[ereptest x;ereplace x;0=type x;.z.s each x;x]}  <<<<<

In last line, it seems $ is applied to 5 arguments, but this page shows $ is of rank 2 or 3. What am I missing here?

Upvotes: 0

Views: 115

Answers (1)

Cathal O&#39;Neill
Cathal O&#39;Neill

Reputation: 3179

From the kx wiki

Odd number of expressions

For brevity, nested triads can be flattened.

$[q;a;r;b;c] <=> $[q;a;$[r;b;c]]

These two expressions are equivalent:

$[0;a;r;b;c]
    $[r;b;c]

Upvotes: 4

Related Questions