Here's a few variants that should get you near where I think you want to be:

   arr e. ,:({:$arr){.'ab'
1 0 0 1 0 0 1 0 0 1
   I.arr e. ,:({:$arr){.'ab'
0 3 6 9
   I.arr e. (0#arr),'ab'
0 3 6 9
   arr ([ I.@e. ] ,~ 0 # [) 'ab'
0 3 6 9

Thanks,

-- 
Raul

On Thu, Aug 28, 2014 at 6:58 AM, Joe Bogner <joebog...@gmail.com> wrote:
> Apologies for the extremely basic question, but I am struggling with
> this after searching NuVoc and the dictionary.
>
> How do I locate all the indices of 'ab' in arr?
>
> arr=:10 $ > ;: 'ab cd yyy'
>
> surely this isn't the best way:
>
> ] (3 = +/"1 'ab' i. arr) # arr
> ab
> ab
> ab
> ab
>
>
> I have been primarily dealing with boxed strings up to this point,
> which seemed easier since it was locating an atom in a list, not a
> list in a table (practicing my vocabulary here... I might be wrong
> though)
>
>
> Thanks,
> Joe
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to