Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!rpi!usc!wupost!darwin.sura.net!haven.umd.edu!socrates!socrates!rockwell
From: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Subject: Re: Array I/O in J.
In-Reply-To: bli@lynx.cat.syr.edu's message of 30 Jan 92 08:54:25 GMT
Message-ID: <ROCKWELL.92Jan30082118@socrates.umd.edu>
Sender: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Organization: Traveller
References: <1992Jan30.035425.2938@newstand.syr.edu>
Date: Thu, 30 Jan 1992 13:21:18 GMT

Bin Li:
   One problem still not clear to me is how to perform the conversions
   between numerical data and character data in J. For example, I use
      (, ,"1&(10{a.) ":array) 1!:2 < 'file_name'         
   to output a 2 dimensional  array.  Then I do this
      infile =. (".;._2) 1!:1 <'file_name' 
   to read it back in.  They look the same but the internal representation of 
   "infile" is neither integer nor floating point number.  How can I convert
   it back to the numerical representation so that mathematical operations 
   can be performed on array "infile"?

I'm not sure I understand the problem.  Here's what I get:
   array=. i. 4 4
   (, ,"1&(10{a.) ": array) 1!:2 <'file_name'

   infile =. (".;._2) 1!:1 <'file_name'
   $infile
4 4
   infile
 0  1  2  3
 4  5  6  7
 8  9 10 11
12 13 14 15
   infile + 3
 3  4  5  6
 7  8  9 10
11 12 13 14
15 16 17 18

I'm not sure what more you could want.

    I understand that using the J internal file system and LinkJ
   together can solve the problem.  I just wonder if there is a
   straight-forward approach to do it.

LinkJ shouldn't be necessary to solve this problem.  On the other
hand, J's internal file system is [imho] rather straighforward to use.

Finally, since we were talking about internal representations in
another thread, let me point out that, in this case, infile is
integer:
   $ a.i. 3!:1 infile
88
   |: 22 4 $ a.i.3!:1 infile
0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0
0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0
0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0
4 1 16 2 4 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

^^^^^^^^^^^^
The header information is:  4 (type integer)
                            1 (references to the data ("infile", and
                                                        not "array"))
                           16 (elements in the array)
                            2 (dimensions in the array)
                          4 4 (shape of the array)

[Just in case anyone is interested in this sort of thing.  [And this
is with J 4.1]]

-- 
Raul Deluth Miller-Rockwell                  <rockwell@socrates.umd.edu>
The U.S. Federal government went another billion dollars into debt today.
