I'm trying to find the index of the first true value:
1b?001b
Expected result: 2
Actual result: ,0b
Two questions:
For your first question, you want to use the where
keyword, which when passed a boolean list will return the indices of the true values:
q)where 00101b
2 4
Use first
in front of the above to obtain what you want.
For your second question, I believe q is casting the left argument of to an int/long and then 'rolling' on the right argument list (see https://code.kx.com/q/ref/deal/).
Example:
q)0b?111b
`boolean$() //return 0 random elements from 111b
q)1b?111b
,1b //return 1 random element from 111b