Of course, if the wrong input mapping is used, a wrong answer is gotten. Apply m=:<:+/2 1*(<a.)[EMAIL PROTECTED]&>' ';TAB,LF instead of m0=:<:+/2 1*(<a.)[EMAIL PROTECTED]&>' ';'+',LF NB. '+'was used for test reasons then ((1;S;m)&;:-:fw2dl) line 1
With Line=:50000 199 $line I get ts'(1;S;m);:"1 Line' NB. Boss 0.21547872 4196864 ts'trim"1 Line' NB. Miller 0.20581284 4196288 ts'fw2dl"1 Line' NB. Bron 2.038465 4200128 ts'(1;S;m);: ,Line' 0.17531539 37750208 ts'trim ,Line' 0.17133324 37749568 ts'fw2dl ,Line' 0.44602124 1.0486099e8 The differences in performance are less than you obtain. As I stated earlier, Miller's solution is leaner than and equivalent with mine. It was a pleasure to help you. R.E. Boss -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Dan Bron Verzonden: dinsdag 6 februari 2007 22:22 Aan: Programming forum Onderwerp: RE: [Jprogramming] Efficiently converting fixed-width to delimited Raul and R.E. Boss, I just ran some metrics of our algorithms on my real dataset: fn fmt TS Name Time Space -------- ------ ------ canon _ _ bron00 23.547 5.500 boss00 1.341 1.000 miller00 1.000 1.000 see postscript for the definitions of these verbs. Raul's results match mine, and his timings are so superior that I threw out my code. R.E. Boss' verb doesn't match the canonical results even in nominal cases: ws =: 2 : '(m&i.)`(,~ n $"_ 0~ $) } :. ( (n&i.)`(,~ m $"_ 0~ $) })' NB. 'X' means data, '.' means space, NB. '=' means TAB, '/' means LF w =: '.=/' ws (' ',TAB,LF) NB. Here's the first line from one of my files. line =: w LF -.~ noun define XXXXXXXX=.XXXXXXX...=.XXX.XXXXX.=.....XXXX=............=.XXX XX=....XXXX=............XXX=...XXXXX..=........=...........X XX=.XXX=..X=.....XXXXXX=...........=..........=........=.... ....=.......XXXXXX/ ) _60 ]\ w^:_1 bron00 line XXXXXXXX=XXXXXXX=XXX.XXXXX=XXXX==XXXXX=XXXX=XXX=XXXXX==XXX=X XX=X=XXXXXX=====XXXXXX/ _60 ]\ w^:_1 miller00 line XXXXXXXX=XXXXXXX=XXX.XXXXX=XXXX==XXXXX=XXXX=XXX=XXXXX==XXX=X XX=X=XXXXXX=====XXXXXX/ _60 ]\ w^:_1 boss00 line XXXXXXXX=.XXXXXXX...=.XXX.XXXXX.=.....XXXX=............=.XXX XX=....XXXX=............XXX=...XXXXX..=........=...........X XX=.XXX=..X=.....XXXXXX=...........=..........=........=.... ....=.......XXXXXX/ Thanks to both of you, -Dan PS: Verb definitions: NB. All verbs may assume y ends with an LF canon =: [: ; [: (dltb@:}: , {:)&.> e.&(10 9{a.) <;.2 ] bron00 =: verb define TAB bron00 y : s =. y ~: ' ' d =. y e. LF,x l =. d ([: ; <@(+./\ );.2) s d =. 1 (0)} d t =. d ([: ; <@(+./\.);.1) s e =. l*.t y =. e#y ) bossS=. _2]\"1 }.".;._2 (0 : 0) ''' '' x;LF Z ']0 1 1 3 1 4 1 1 0 3 1 4 1 2 0 3 1 4 2 1 2 3 2 4 2 2 2 3 2 4 2 ) boss00 =: (1;bossS;<:+/2 1*(<a.)[EMAIL PROTECTED]&>' ';'+',LF )&;: "1 NB. other SPACE DELIM millerS=.0 10#:10*".;._2]0 :0 2.1 0.0 1.1 2.2 0.3 1.2 2.0 3.2 1.2 2.2 3.0 1.1 ) miller00=: (1;millerS;(a.=' ')+2*a.e.LF,TAB)&;: NB. w =: fread jpath '~temp\fw2dl.txt' (verb define) bron00`boss00`miller00 NB. canon` TS =: 0 $~ 2,~#y for_v. y do. smoutput 'timing ',;v TS =: (6!:2 '0 0 $',(;v),' W') (<v_index;0) } TS 6!:3]0.5 smoutput 'spacing ',;v TS =: (7!:2 '0 0 $',(;v),' W') (<v_index;1) } TS 6!:3]0.5 end. ) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm