Benedict G Archer wrote:
Been playing with J for a year+ and can do some useful things, but
thought a good way to advance would be to use J for things I do all the
time. Gave 40 students a chem test with 80 questions and have an array
with the first column containing student names and the remaining
columns for scores on each question. The task is to evaluate the test
questions--e.g., which did everyone get right, any that everyone
missed, etc. I'm trying to write the array to a file in a way that I
can get it back easily and work with it. In APL2 I could save a
workspace; in Matlab or Octave I could save a file, but haven't been
able to figure out how to write the J noun to a file and get it back.
'm' fread, after fwrite, seems to count the box characters as part of
the array, and freads isn't useful, at least in my attempts, either.
Do I need to use a mapped file? I expect to be red-faced when someone
tells me where the answer is in the help docs or the lab that shows
how, but it's time for me to admit I need help. Suggestions on a best
J approach to this simple task also welcome.
You can use 3!:1 & 3!:2 to convert J nouns to and from a binary
representation which can be stored on file, e.g.
(3!:1 i. 2 3) fwrite 'temp\t1.dat'
48
3!:2 fread 'temp\t1.dat'
0 1 2
3 4 5
Alternatively, use the J files package (User Manual|J Files), which
provides cover functions to do this.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm