[Jprogramming] locating indices of string in list of strings

Henry Rich HenryHRich at nc.rr.com
Thu Aug 28 12:09:09 UTC 2014


One problem is, the string 'ab' does not exist in arr.  When you opened 
arr you padded the strings to a common length.

'ab ' would be in arr, but you have the arguments to i. reversed.  x is 
the search space, y is the value you are looking for.

Henry Rich

On 8/28/2014 6:58 AM, Joe Bogner 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
>


More information about the Programming mailing list