PackRat wrote:

>  Diskfile:    Vector: . . . . . . . . .     Diskfile:
> 
>  3<CR><LF> --> 3 1 2 --> sort* --> 1 2 3 --> 1<CR><LF>
>  1<CR><LF>                                   2<CR><LF>
>  2<CR><LF>                                   3<CR><LF>

This is pretty easy.   Here's an example input:

           
           Y =:  '3',LF,'2',LF,'1'

and output:

           Z =:  '1',LF,'2',LF,'3'

and import/export engine:

           io   =:  =&LF `(,:&' ') }  :. ( =&' '`(,:&LF ) } )
           ns   =:  0&". :. ": NB.  Don't use monad  ".

           go   =:  ns@:io
           
           ugo  =:  &.go
           
           /:~ ugo Y           NB.  /:~ could be any monad
        1
        2
        3

           Z -: /:~ ugo Y      NB.  Output in expected format
        1
           
I submitted a couple of feature requests today which would it possible to 
express  go  this way:

           go  =:  0 ". =&LF `(,:&' ') }

which is shorter and cleaner.  See here:

        
http://www.jsoftware.com/jwiki/System/Interpreter/Requests#head-8e4b0cee2bf8eeb353250cb13fc37dfd52801ae3

-Dan

PS:   I wonder if the Forum can come up with the shortest, cleanest method 
which J currently supports.  

If we're being strict, and your line terminators are CRLF, the fuller solution 
would be:

    go =: ns@:io@:(-.&CR :. (#!.CR~ 1 |. 1 j. =&LF))

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

Reply via email to