cancel
Showing results for
Did you mean:

## This Example Demonstrates the Seeming Inconsistencies in the Find

New Contributor

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

q)0 1 2 ? (0 1; 2)

0 1

2

Here are the 4 cases with 2-item general lists as the operands

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

Obviously the first item of a general list being atomic (recursively) or not bears on the results.

New Contributor
I believe the following rules, if adopted, would greatly reduce the complexity of the domain of the find (?) operator and several others:

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 operands

q)(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