# This Example Demonstrates the Seeming Inconsistencies in the Find

**URL:** <https://forum.kx.com/t/this-example-demonstrates-the-seeming-inconsistencies-in-the-find/10109>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [July 12, 2015, 6:07pm UTC](https://forum.kx.com/t/this-example-demonstrates-the-seeming-inconsistencies-in-the-find/10109 "2015-07-12T18:07:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erik\_friis1](https://avatars.discourse-cdn.com/v4/letter/e/ee59a6/32.png) [@erik\_friis1](https://forum.kx.com/u/erik_friis1)\
**Post date:** [July 12, 2015, 6:07pm UTC](https://forum.kx.com/t/this-example-demonstrates-the-seeming-inconsistencies-in-the-find/10109/1 "2015-07-12T18:07:00Z")

</div>

I think this example shows at least what is not documented in the Borror book. &nbsp;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.

Thanks for any insight/comments.

---

<div class="post-metadata">

**Author:** ![erik\_friis1](https://avatars.discourse-cdn.com/v4/letter/e/ee59a6/32.png) [@erik\_friis1](https://forum.kx.com/u/erik_friis1)\
**Post date:** [July 15, 2015, 7:06am UTC](https://forum.kx.com/t/this-example-demonstrates-the-seeming-inconsistencies-in-the-find/10109/2 "2015-07-15T07:06:00Z")

</div>

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

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rightoperand is an atom or list (simple or nested)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?applied atom-wise to right operand

&nbsp;

Left operand is a nested list

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rightoperand is an atom or list (simple or nested)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?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) &nbsp;/ would be (0; 1 2)
> 
> 'type
> 
> q)0 1 2 ? (::; 0; 1 2) &nbsp;/ would be (3; 0; 1 2)
> 
> 'type
> 
> q)0 1 2 ? ((0; 1 2); 1 2) &nbsp;/ would be ((0; 1 2); 1 2)
> 
> 'type
> 
> q)0 1 2 ? (0 1; 2) &nbsp;/ would be same (0 1; 2)&nbsp;
> 
> 0 1
> 
> 2
> 
> Here are the 4 cases with 2-item general lists as the operands
> 
> q)(1 2; 3)?(3; 1 2) &nbsp;/ would be 1 0
> 
> 2
> 
> q)(1 2; 3)?(1 2; 3) &nbsp;/ would be same 0 1
> 
> 0 1
> 
> q)(3; 1 2)?(1 2; 3) &nbsp;/ would be 1 0
> 
> 2 2
> 
> 0
> 
> q)(3; 1 2)?(3; 1 2) &nbsp;/would be same 0 1
> 
> 0 1
