[Jprogramming] Problem working with data loaded from a file
Dan Bron
j at bron.us
Fri Mar 30 09:13:30 HKT 2012
In J, a string is represented as a _box- containing a vector of characters. Because < makes an atom of its argument, the = operation works as you'd expect. For example:
Please excuse typos; composed on a handheld device.
-----Original Message-----
From: "PackRat" <packrat at anet.com>
Sender: programming-bounces at jsoftware.com
Date: Thu, 29 Mar 2012 19:59:13
To: Programming forum<programming at jsoftware.com>
Reply-To: Programming forum <programming at jsoftware.com>
Subject: Re: [Jprogramming] Problem working with data loaded from a file
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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list