sv/:string vs. sv string/:

q)aabcdefghijkq)m:0N 3#aq)mabcdefghijkq)q)"+" sv/:string each m"a+b+c""d+e+f""g+h+i""j+k"q)q)/ why doesn't this work?q)"+" sv string/:m'/: [0] "+" sv string/:m ^

q has Noun, Adverb and Verb
it seems that q allows NNA as in "+"sv/:
but not NA as in string/:

it does allow NVA as in string@/:

N and V are terms, so it seems q allows NtA

It has to do with the arity of the verb or function.

Adverbs such as “each-both”, “each left” and “each right” are supposed to be applied to dyadic verbs or functions (e.g., sv).

The equivalent adverb for monadic verbs of functions (e.g., string) is “each”.

string@/:m works because “@” in this case is applied in its dyadic form to the arguments “string” and “m”.

HTH,

Davide Corti | KDB+ Engineer | Kx | +44-7926-223284 | dcorti@kx.com

>supposed to be applied to dyadic verbs or functions

q)+/1 2 3

'/

Hi Jack,

The adverb you are using in this case is “over”.

To apply it to your last example, you need brackets:

q)(+/)1 2 3

6

The adverb we were considering previously is “each-right”.
You can use it with “+” for instance as follows:

q)1+/:1 2 3

2 3 4

q)1 2+/:4 3 2

5 6

4 5

3 4

Regards,

Davide Corti | KDB+ Engineer | Kx | +44-7926-223284 | dcorti@kx.com

Thanks Davide,

It does appear that /: needs a dyad with an initial value to the left:

q)3 {x,y}/:(0 1;2 3;4 5)

3 0 1

3 2 3

3 4 5

[as the reference states]

it also appears to apply to other adverbs:

q)0+/1 2 3

6

so (NtAe) is a q expression:

q)0{y*y}'til 4

0 1 4 9

jack