q @ 符号在用作函数调用的上下文中做什么?

What is the q @ symbol doing in the context of being applied as a function call?

这里的例子是怎么回事?

来源:http://code.kx.com/q/ref/select/#index-at

@[d;1 1 1;+;3]
((1 2 3;4 5 6 7);(17 18;19;20 21);(13 14;15 16 17 18;19 20))

http://code.kx.com/wiki/JB:QforMortals2/functions#Functional_Forms_of_Amend

@[L;I;f;y]
L=your list
I=index of elements to modify
f=function to apply
y=2nd parameter to f

您可以通过将 + 放在一个函数中并添加一些日志输出来查看它在做什么。在这种情况下,它索引到第二个元素 d@1,检索 (8 9;10;11 12),添加 3,结果为 (11 12;13;14 15),将其用作下一个输入,添加 3,结果为 (14 15;16;17 18) .

    q)@[d;1 1 1;{0N!("x is:",.Q.s1 x;"y is:",.Q.s1 y);x+y};3]
    ("x is:(8 9;10;11 12)";"y is:3")
    ("x is:(11 12;13;14 15)";"y is:3")
    ("x is:(14 15;16;17 18)";"y is:3")
    (1 2 3;4 5 6 7)
    (17 18;19;20 21)
    (13 14;15 16 17 18;19 20)

或者使用over(/):

也可以看到
    q)@/[d;;{0N!(x;y);x+y};3]1 1 1
    ((8 9;10;11 12);3)
    ((11 12;13;14 15);3)
    ((14 15;16;17 18);3)
    (1 2 3;4 5 6 7)
    (17 18;19;20 21)
    (13 14;15 16 17 18;19 20)