I have the opposite view on convenient cover functions. Given source and
target files S, T, then this can be done with:

T fwrites~ ; LF,~ each sort 'b' fread S


I think this is a lot more readable than sortfile, and it does take care of
line endings, as well as calling jpath on the file name.


On Tue, May 28, 2013 at 6:04 AM, Joey K Tuttle <[email protected]> wrote:

> ...



> The original question of how to sort the lines of a text file could be
> written, with no cover functions at all, as -
>
>    sortfile=: ([:;[:/:~[:<;.2[:][:1!:1<)1!:**2[:<'sorted.'"_,]
>
> Where the output file is prefixed with 'sorted.' to avoid destroying the
> original file. I'm sure that (13 : generated) tacit definition could be
> made more readable - but the point is that having "convenient cover
> functions" can make things obscure in a different way. Note that sortfile
> completely avoids the issues around "line end character(s)" and works for
> lines ending with CR, LF, or CR,LF.
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to