On 26 May 2013 15:32:47 -0600, Don Guinn <dongu...@gmail.com> wrote:
That does it; thanks! But how do you know about the optional 'b' argument of fread? I cannot find documentation about fread at all -- either in J701 or J801 using scriptdoc or in the help pages, included with J or on-line. Where did you find that documented? And if it's not in the documentation, is this something one is just supposed to intuit, or know only if he's a member of some secret cult and is told as part of initiation rites? > sortandprint=:4 : 0 > > text=.'b' fread y > > text=./:~text > > text=.text,&.>LF > > (;text) fwrite x > > ) > > > The 'b' option means box each line. > > > y is file to read, > > x is file to write sorted. > > > If you are dealing with windows and need CRLF as a line separator, replace > the LF with <CRLF. > > > On Sun, May 26, 2013 at 1:50 PM, Murray Eisenberg > <mur...@math.umass.edu>wrote: > >> 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. --- 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