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.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to