Find one list inside another.

I’m doing the following:

g: (1;(1 2)

n: (1 2 2)

then, 

g?n - based on the page http://code.kx.com/wiki/Reference/QuestionSymbol#find - I seem to be doing it correct. However, I get the answer as ,1. 

Why is the find reporting “n” as found inside “g”?  And how do I fix it? 

Thanks, 

Kumar

find (?) is atomic right, meaning that it treats each element of a list on the right hand side separately.
i don’t know what you’re actually doing but i suspect it’s not exactly what you said.
console snapshots are always best for questions like these.

q)g:(1;(1 2)) /note your example is missing a )
q)n:(1 2 2) /note the () are redundant here
q)g?n
0 2 2
q)/first element of n, 1, is found in the 0th position of g
q)/second and third elements of n, 2 2, are not found and so count[g] is returned for each of them
q)

hope this helps,
mike

Thanks a lot, Mike. I’m now using the code :

q)g                    

1                      

1 2                    

q)nxt                  

1 2                    

q){where x~:y}[g;nxt] 

`long$()

q)

I check for empty list return(i.e - `long$()) by doing a count of the return value. 

Kumar 

Sorry, nxt was 1 2 2 in the above example. 

q)g                    

1                      

1 2                    

q)nxt                  

1 2  2                 

q){where x~:y}[g;nxt] 

`long$()

I check for empty list return(i.e - `long$()) by doing a count of the return value. 

Kumar