Newsgroups: comp.lang.apl
Path: watmath!ljdickey
From: ljdickey@math.uwaterloo.ca (L.J. Dickey)
Subject: Re: J verb for reading a file into J
Message-ID: <Bw159F.730@math.uwaterloo.ca>
Organization: University of Waterloo
References: <1992Oct11.064814.13447@csus.edu>
Date: Mon, 12 Oct 1992 22:32:02 GMT

In article <1992Oct11.064814.13447@csus.edu> vpcsc4@sfsuvax1.sfsu.edu (Emmett McLean) writes:
>
> Does some one have a J verb which reads a file
> and translates it into a character matrix? Presently
> I am using an intermediate C program which inserts
> the strings "w =. w, ' " "'" which seems real 
> inefficient.
> 
> Thanks.
> Emmett vpcsc4@sfsuvax1.sfsu.edu


Greetings from London.

I am now in London, visiting Royal Holloway Bedford New College until the
end of November.  If you wish to reach me there, you may try

	ljdickey@cs.rhbnc.ac.uk

but mail sent to the old address will reach me still.

Here is a session script that seems to solve this problem for me.  If
this does not exactly work for you, perhaps some variant of it will.
I say this because it may depend on what character your system uses
for end of line character, and whether or not your system includes
the end of file marker in the file itself.  

The system I am working on tonight is a decsystem of some flavor (how
can one know?), running Ultrix 4.2a.

My profile.js had only two lines of information, but I slipped in a
blank line just to see if the method would work with blank lines too.  Here
My steps are:

	read the file 'profile.js'
	write the function 'boxer'
	apply disclose to the result of using boxer.

In the listing below, you will see an example of the use of the linear
representation (9!:3), and an example of the use of fix verb (f.).
I have found these last two features expecially useful in building up
functions in tacit form.

							Lee Dickey



 -=- -=- -=- -=- -=- -=- -=- -=- begin session -=- -=- -=- -=- -=- -=- -=- -=- 

% J
J5.1a   Copyright (c) 1990-1992, Iverson Software Inc.  All Rights Reserved.

   scr=.0!:2&<
   
   read=.1!:1&<
   
   scr 'out'
   
   fn =. 'profile.js'
   display =. 9!:3
   display 5   

   y =. read fn
   y
scr=.0!:2&<

read=.1!:1&<

   boxer =. < ;. _2
   boxer y
+-----------++------------+
|scr=.0!:2&<||read=.1!:1&<|
+-----------++------------+
   > boxer y
scr=.0!:2&< 
            
read=.1!:1&<
   $ > boxer y
3 12
   f =. > @ boxer @ read
   a. i. z =. f fn
115  99 114  61 46 48 33 58 50 38 60 32
 32  32  32  32 32 32 32 32 32 32 32 32
114 101  97 100 61 46 49 33 58 49 38 60
   $ z
3 12
   f
>@boxer@read
   f f.
>@(<&}:;.2)@(1!:1&<)

 -=- -=- -=- -=- -=- -=- -=- -=- end session -=- -=- -=- -=- -=- -=- -=- -=- 
 


-- 
Prof. Leroy J. Dickey, Faculty of Mathematics, U of Waterloo, Canada  N2L 3G1
   Internet:      ljdickey@math.UWaterloo.ca
                  ljdickey@math.waterloo.edu
   UUCP:          ljdickey@watmath.UUCP
