(Posted to Programming forum, where it belongs.)
<"2([:({:{./."_ _1 ]) {.,: >./\@{:)(4&{.,:&|: _4&{.)|:/:~([:". (('.',CR),:' ')rpl3a ]);._2 (1!:1< fiprs) +--------------+---------------+ | 0 8 218 247|139 190 53 1| | 0 21 67 252|181 190 92 6| | 0 24 19 98|181 190 92 140| | 0 35 103 193|187 252 204 140| | 0 45 34 152|187 252 204 156| | 0 71 61 171|187 252 232 156| | 0 107 80 62|228 252 232 225| | 0 110 127 170|228 252 238 225| | 0 135 106 4|228 252 238 253| | 0 145 92 142|244 252 238 253| | 0 209 167 136|244 252 245 253| | 2 81 94 131|244 252 248 253| | 2 133 215 228|244 252 248 254| | 4 38 177 206|249 252 248 254| | 5 185 121 67|249 252 251 254| | 6 84 246 238|249 252 252 254| | 9 159 124 168|249 252 254 254| |11 190 131 164|253 252 254 254| |15 123 7 161|253 253 254 254| |16 121 164 44|253 254 254 254| |65 61 160 76|254 254 254 254| +--------------+---------------+ with (see http://www.jsoftware.com/pipermail/programming/2007-July/007302.html ) rpl3a =: 4 : 0 'x0 x1'=. x ((x1,a.) {~ (x0,a.) i. ]) y ) It is obvious that the only check needed is ip < first=: 0 8 218 247 or ip>last=: 254 254 254 254 Although I know ip should be checked one address at the time, I have ts'ips=: _4[\ ". ((''.'',CR),:'' '')rpl3a ]; <;._2(1!:1<fips)' 0.6652637 6.8565171e8 vs. ts' makeNum2 }:;._2 (1!:1<fips)' 1.7109301 1.7813939e8 ts 'task2 0' 1.7599606 1.7814042e8 ts'(first,:last)((<{:)+.(>{.))~"_ 1 ips=: _4[\ ". ((''.'',CR),:'' '')rpl3a ]; <;._2(1!:1<fips)' 1.2593654 6.8565325e8 Faster, but fatter. R.E. Boss > -----Oorspronkelijk bericht----- > Van: chat-boun...@jsoftware.com [mailto:chat-boun...@jsoftware.com] > Namens Aai > Verzonden: woensdag 14 december 2011 20:04 > Aan: Chat forum > Onderwerp: Re: [Jchat] 4 questions > > Maybe it's by coincidence but if I do not correct the ip MSD (makeNum) > then the output is the same. > > ts 'P2=. task2 0' > 5.61973 1.17707e8 > Q-:P2 > 1 > > > makeNum2=: 256 #. [: ". =&'.'`(,:&' ')} > > task2=: 3 :0 > IP=. }:;._2 (1!:1<fips) > IPR=. }:;._2 (1!:1< fiprs) > ips=: makeNum2 IP > 'a b c'=. |: ;:"1 IPR > 'l r'=:(/:{."1)&. |:a ,:&makeNum2 c > m =: 0,(1+>./ @: {.&r)"0 (1+i.#l) > G=: 2 | (,(~.}.m) ,.~ (}.m) {./. l) I. ] > G ips > ) > > > > On 14-12-11 17:41, I wrote: > > To be clear, I made a total task of all the actions to see what the > > time consuming part was. That happened to be (of course) the > > converting part. So I made a faster converter. > > > > What exactly do you want as output? > > > > Do you want something like > > (#~G )ips > > 1590633180 365671447 69450821 _1260155495 _867958750 574796455 > > 329735247 .... > > > > selecting where G has a one? > > > > So in the meantime reading/converting and verb f are optimized. > > > > > > > > On 14-12-11 17:10, Alexander Epifanov wrote: > >> How is it possible to output G without inlined array? > >> The same question is for boxed view: 5!:2<'F' - it does not possible > >> to read, because it looks like ----------------... > >> | ||_2147483648 197014786 890854407 1006423136 1685034722 > 1956788740 > >> 2040340624 > >> 2099004718 2108694720 2121608906 2123216303 2123418208 2124269825 > >> 2124437712 212 > >> 5836382|+-+-+|+------------------------------------------------------------- ---- > >> > >> ----------------... > >> > >> Thank you, > >> > >> On Wed, Dec 14, 2011 at 5:04 PM, Aai<agroeneveld...@gmail.com> > wrote: > >>> Using Raul's G total timing becomes > >>> > >>> ts 'P=.task 0' > >>> 5.68436 1.17707e8 > >>> P-:Q > >>> 1 > >>> > >>> FYI > >>> > >>> > >>> > >>> On 14-12-11 15:39, I wrote: > >>>> Here's a first speedup: > >>>> > >>>> ( thanks Dan: (OLD&=)`(,:&NEW) } ) > >>>> > >>>> timing of your program: > >>>> > >>>> ts 'Q=.AE 0' > >>>> 30.4894 1.05856e8 > >>>> > >>>> > >>>> speedup by converter makeNum > >>>> > >>>> > >>>> ts 'P=.task 0' > >>>> 5.79403 1.17706e8 > >>>> > >>>> P-:Q > >>>> 1 > >>>> > >>>> makeNum=: 256 #. 128 0 0 0 -"1~ [: ". =&'.'`(,:&' ')} > >>>> > >>>> task=: 3 :0 > >>>> IP=. }:;._2 (1!:1<fips) > >>>> IPR=. }:;._2 (1!:1< fiprs) > >>>> ips=. makeNum IP > >>>> 'a b c'=. |: ;:"1 IPR > >>>> a =. makeNum a > >>>> c =. makeNum c > >>>> 'l r'=._1 0+ (/:{."1)&. |:a,:c > >>>> m =. (pip'0.0.0.0'),(1+>./ @: {.&r)"0 (1+i.#l) > >>>> f =.< m {~ I.~&l > >>>> f"1 ips > >>>> ) > >>>> > >>>> =============== > >>>> Your program > >>>> =============== > >>>> pip =: (256 #. (-&128 @: {.) , }.) @: (".;._2@:,&'.') > >>>> > >>>> AE=: 3 :0 > >>>> ips =. pip"1 (_1&}.;._2 (1!:1<fips)) > >>>> iprs =. |:pip;._1 "1 (','&,)"1 (_1&}.;._2 (1!:1<fiprs)) > >>>> i =. /:{.iprs > >>>> l =. _1+ i{{.iprs > >>>> r =. i{{:iprs > >>>> m =. (pip'0.0.0.0'),(1+>./ @: {.&r)"0 (1+i.#l) > >>>> NB. m =: __,(1+>./ @: {.&r)"0 (1+i.#l) > >>>> f =.< m {~ I.~&l > >>>> f"1 ips > >>>> ) > >>>> > >>> -- > >>> Met vriendelijke groet, > >>> @@i = Arie Groeneveld > >>> > >>> ---------------------------------------------------------------------- > >>> For information about J forums see > http://www.jsoftware.com/forums.htm > >> > >> > > > > -- > Met vriendelijke groet, > @@i = Arie Groeneveld > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm