Perhaps you can make (a part of) ips.txt available on dropbox as well. Then we could test a bit.
R.E. Boss > -----Oorspronkelijk bericht----- > Van: [email protected] [mailto:[email protected]] > Namens Alexander Epifanov > Verzonden: woensdag 14 december 2011 11:14 > Aan: Chat forum > Onderwerp: Re: [Jchat] 4 questions > > Hello again, > Here my optimized version with ints, its 1.5 faster then float solution. > http://dl.dropbox.com/u/34917039/ip.j > > The main thing: it is much faster than K! > > Could you let me know, is it possible to optimize time of "f" function? > I tryed to represent IP like 4 ints: 192 168 1 1, but this solution > works much slower. > > ips.txt: file with ip addresses > ipr.txt: file with ip ranges: ip,ip > > And the other thing I cannot understand: > 5?5 > 4 1 0 2 3 > 10?5 > |domain error > | 10 ?5 > ??? > > Thank you, > > On Fri, Dec 9, 2011 at 10:53 PM, Alexander Epifanov <[email protected]> > wrote: > > Hello, > > > > On Fri, Dec 9, 2011 at 3:11 PM, Raul Miller <[email protected]> wrote: > >> On Fri, Dec 9, 2011 at 7:50 AM, Alexander Epifanov > <[email protected]>wrote: > >> > >>> Hello, > >>> > >>> I made my first application on J. > >>> I was surprised that it works faster than K: > >>> > >>> pip =: 256 #. x:@:".;._2@:,&'.' > >>> ips =: pip"1 (_1&}.;._2 (1!:1<'ips.txt')) > >>> iprs =: |:pip;._1 "1 (','&,)"1 (_1&}.;._2 (1!:1<'ipr.txt')) > >>> i =: /:{.iprs > >>> l =: i{{.iprs > >>> r =: i{{:iprs > >>> m =: 0,(>./ @: {.&r)"0 (1+i.#l) > >>> f =: <: m {~ I.~&l > >>> 6!:2 'f"1 ips' > >>> > >>> But I suppose that it could be better: > >>> 1) It uses x:, but IP address could fill int, I found that J does not > >>> support unsigned int (K also). > >>> But unfortunately, I cannot find the way in J how to convert 4 numbers > >>> into signed int i J. > >>> > >> > >> Why are you concerned about data representation type? This works fine: > >> > >> pip =: 256 #. ".;._2@:,&'.' > >> > >> > > Yes, it works, but 3!:0 pip'192.168.1.1' - float, But I suppose that > > int would be faster, I would like to compare. > > > >>> > >>> 2) How is it possible to change m =: 0,(>./ @: {.&r)"0 (1+i.#l) > >>> without right brackets? I expected something like ... "0 @: 1 + i.#l, > >>> but it does not work. I think that "0 +&1 i.#l is not best solution. > >>> > >> > >> I do not have any ipr.txt so I do not know what domain m is intended for. > >> I could guess, but right now I do not understand your question. > >> > >> > >>> 3) ips =: pip"1 (_1&}.;._2 (1!:1<'ips.txt')) is very slow, in pip > >>> function, is it possible to make it faster? > >>> > >> > >> Getting rid of x: should make pip faster. I also suspect you want > >> something like this: > >> > >> ips=: pip;._2 (1!:1 <'ips.txt') -. CR > > Thanks! it works twice faster. > >> > >> Or: > >> > >> ips=: 256 #. 0&".;._2 ' ' (I.@e.&('.',CR)@])} 1!:1<'ips.txt' > >> > >> > >>> 4) I cannot find in VOC is I. binary search or something like that? > >>> > >> > >> Typically, yes. > >> > >> -- > >> Raul > >> ---------------------------------------------------------------------- > >> For information about J forums see > http://www.jsoftware.com/forums.htm > > > > > > > > -- > > Regards, > > Alexander. > > > > -- > Regards, > Alexander. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
