I'm really out of practice with J, and the meager-to-nonexistent documentation 
is not helping me. I have a very simple task to perform. I have a text file 
infile.txt on my desktop and here's what I want to do:

 (1) read the file as lines (so I don't get all the end-of-line symbols);
 (2) sort the file's lines (alphabetically)
 (3) write out the result as a new text file, say outfile.txt, also on my 
desktop.

I can do this trivially in Mathematica:

 t = Import["~/Desktop/infile.txt", "Lines"]
 Export["~/Desktop/outfile.txt", Sort[t]]

But how would I do this in J (which, for longer files, ought to be faster) and 
how would I discover how to do it? I prefer to use named library functions 
where applicable.

I tried the following in J801, after looking into text.ijs from J602:

  load 'files'
  t=. fread '~/Desktop/infile.txt
  load 'text'
  cuttext t
| value error: cuttext

What happened there?

[Hope this is not too basic for this forum (as compared with 
gene...@forums.jsoftware.com).]

---
Murray Eisenberg                                    mur...@math.umass.edu
Mathematics & Statistics Dept.       
Lederle Graduate Research Tower            phone 413 549-1020 (H)
University of Massachusetts                               413 545-2838 (W)
710 North Pleasant Street                         fax   413 545-1801
Amherst, MA 01003-9305





----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to