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

Reply via email to