[Jprogramming] Problem working with data loaded from a file

PackRat packrat at anet.com
Fri Mar 30 08:59:13 HKT 2012


Devon McCormick wrote:
> So is this an accurate, if simplified, representation of what you want to do?
> 
>    str0=. ,&.>'A';'B';'NG';'Yow'
>    col2search=. ,&.>'A';'a';'AA';'B';'BB';'C';'CC';'Foo';'Zowie';'NG'
>    col2search e. str0
> 1 0 0 1 0 0 0 0 0 1
>    str0 i. col2search   NB. Which element of "str0" found where? (4 is
> not found)
> 0 4 4 1 4 4 4 4 4 2
> 
> The only real trick is raveling the elements of each item (,&.>) to
> ensure that they are all vectors.

This is becoming far more complex than what I was seeking.

Versions and variations of the BASIC computer language are the 
languages I'm most familiar with prior to J.  What I was trying to 
accomplish is similar to this in BASIC:

   If x$ = y$ Then <do some action>

If x$ and y$ are two strings (literals, in J parlance) which contain 
exactly the same characters in exactly the same order, then they would 
be considered "equal", and the logical value passed to "If" would be 
"true", which makes the "Then" action occur in BASIC; otherwise not.

The same logic of a series of successive "if"/"elseif" statements in J 
occurs in a "select..case" construct, which was my original preferred 
approach.  I turned to "if" because I couldn't seem to get the "select" 
construct to work.

Does this clarify better what I was trying to do?


Harvey



More information about the Programming mailing list