2015.07.12 10:07 AM
I think this example shows at least what is not documented in the Borror book. The operator changes its behavior depending on the first element of the right and left operands when they are general lists.
I know that the operator is supposed to be atomic in the right operand when the left operand is a simple list but even that rules seems to have exceptions:
q)0 1 2 ? (0; 1 2)
'type
q)0 1 2 ? (::; 0; 1 2)
'type
q)0 1 2 ? ((0; 1 2); 1 2)
'type
0 1
2
q)(1 2; 3)?(3; 1 2)
2
q)(1 2; 3)?(1 2; 3)
0 1
q)(3; 1 2)?(1 2; 3)
2 2
0
q)(3; 1 2)?(3; 1 2)
0 1
2015.07.14 11:06 PM
Left operand is a simple list
Rightoperand is an atom or list (simple or nested)
?applied atom-wise to right operand
Left operand is a nested list
Rightoperand is an atom or list (simple or nested)
?applied item-wise to right operand
With these rules I'll provide the proposed (would be) results below:
q)0 1 2 ? (0; 1 2) / would be (0; 1 2)
'type
q)0 1 2 ? (::; 0; 1 2) / would be (3; 0; 1 2)
'type
q)0 1 2 ? ((0; 1 2); 1 2) / would be ((0; 1 2); 1 2)
'type
q)0 1 2 ? (0 1; 2) / would be same (0 1; 2)0 1
2
Here are the 4 cases with 2-item general lists as the operandsq)(1 2; 3)?(3; 1 2) / would be 1 0
2
q)(1 2; 3)?(1 2; 3) / would be same 0 1
0 1
q)(3; 1 2)?(1 2; 3) / would be 1 0
2 2
0
q)(3; 1 2)?(3; 1 2) /would be same 0 1
0 1
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.