Accumulator gives different result then direct function applying

130 Views Asked by At

Trying to combine two result sets I've faced with different behavior when joining two keyed tables:

q)show t:([a:1 1 2]b:011b)
a| b
-| -
1| 0
1| 1
2| 1
q)t,t
a| b
-| -
1| 1
1| 1
2| 1
q)(,/)(t;t)
a| b
-| -
1| 1
2| 1

Why does the accumulator ,/ remove duplicated keys, and why its result differs from a direct table join ,?

1

There are 1 best solutions below

0
terrylynch On BEST ANSWER

I suspect that join over (aka ,/ aka raze) has special handling under the covers that isn't exposed to the end user.

The interpreter recognises the ,/ and behaves a certain way depending on the inputs. This likely applies to dictionaries and keyed tables:

q)raze(`a`a`b!1 2 3;`a`b!9 9)
a| 9
b| 9
q)
q)(`a`a`b!1 2 3),`a`b!9 9
a| 9
a| 2
b| 9
q)
q)({x,y}/)(`a`a`b!1 2 3;`a`b!9 9)
a| 9
a| 2
b| 9