R.E. Boss wrote:
tolower is not the fastest you can get. Hui gave in
http://www.jsoftware.com/pipermail/programming/2007-July/007302.html
rpl3a=: 4 : 0
 'x0 x1'=. x
 ((x1,a.) {~ (x0,a.) i. ]) y
)

   5 ts 'tolower y'[y=.a.{~1e6 [EMAIL PROTECTED] 256
0.024976126 8523008
  5 ts ' (((65,.97)+"0 _ i.26){a.)rpl3a y'
0.0051314348 1054400

almost 40 times more efficiënt.

  (tolower y) -:(((65,.97)+"0 _ i.26){a.)rpl3a y
1

The rpl3a method was essentially that used in J504, but replaced in J6 with a slower method that works with unicode, e.g.

   [A =: 3 2$'aBc' , (u:39321 28207), 'E'
aB
c香
港E

   toupper A
AB
C香
港E

   (((65,.97)+"0 _ i.26){a.)rpl3a A
|index error: rpl3a
|       ((x1,a.){~(x0,a.)i.])y

On the other hand, a 40x hit is quite a lot. It would be good to speed up toupper and still work with unicode.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to