Devon, Henry, Raul,

  Thanks, I see it all clearly now :-)
There is the problem with J documentation that lots
of info is out there but it's scattered in various
places. Though in this case it was where I should
have looked first. There was a red herring in my case:
one of the 90 column headings was 'y', which had thus
been assigned by the right argument of the calling verb.
That generated an error that confused me before I saw
that I needed to insert an
   erase 'y'
before the assignment.
  I like the idea of a pre-assignment check of the
valadity of the column names, and modification of them
if needed. Though in my case the code generating the
file is fortran, so all the names are good.

                        Thanks,
                                Patrick

On Sun, 25 May 2014, Henry Rich wrote:
Look at

http://www.jsoftware.com/jwiki/Vocabulary/Assignment

Henry Rich

On 5/25/2014 12:58 PM, J. Patrick Harrington wrote:
I've always liked this economy of assignment:
'e f g'=. s=. >1 2;3 4;5 6
   f
3 4
   e
1 2
-- but I wondered if it were possible to extend this where the left hand
side is not explicit:
    abc=. 'a';'bb';'ccc'
┌─┬──┬───┐
│a│bb│ccc│
└─┴──┴───┘
I found I could make a single assignment:
    (>1{abc)=. 1{s
    bb
3 4
   a
|value error: a
But I didn't want to put this into a loop.
It was neat to find that I could write:
    (abc)=. s
    a
1 2
    bb
3 4
   ccc
4 5
   abc
┌─┬──┬───┐
│a│bb│ccc│
└─┴──┴───┘
   This is useful in working with data files output
by a stellar evolution program where I have ASCII tables with 90 columns
and over 1000 rows, and each
column has a name 1 to 25 characters long: I wanted
to read this into a J session, assigning the column
values to each of the respective names. Turns out it
can be done with one line of the form
    (head)=: data_array
where
    head

┌────┬────┬──────┬────┬────┬──────────┬────────┬─────────────────────────┬───────────────────┬─


│zone│logT│logRho│logP│logR│luminosity│eps_grav│log_abs_eps_grav_dm_div_L│signed_log_eps_grav│..


└────┴────┴──────┴────┴────┴──────────┴────────┴─────────────────────────┴───────────────────┴─

(see http://www.astro.umd.edu/~jph/mesa_read.ijs) Another example of the
"black hole of J".

I don't know where in the documentation this can be
found - I just got there by experimentation.

                                        Patrick

P.S. This started as a post asking for
      help in getting rid of a loop, but
      I found the solution along the way.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
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