The space used in the benchmarks indicates that you did them in J6.02. The benchmarks benefited from special code new in J6.02. See file:///C:/j602/help/release/charmap.htm in the release notes.
----- Original Message ----- From: Raul Miller <[EMAIL PROTECTED]> Date: Friday, December 21, 2007 6:47 Subject: Re: [Jprogramming] rosetta code - change case To: Programming forum <[email protected]> > On Dec 21, 2007 8:22 AM, Jack Andrews <[EMAIL PROTECTED]> wrote: > > upper=: (a.,~a.{~65+i.26) {~ (a.,~a.{~97+i.26) i. ] > > lower=: (a.,~a.{~97+i.26) {~ (a.,~a.{~65+i.26) i. ] > > seems a little unwieldy... are there better ways? > > Sure. > > For example (with my verb display set to linear): > (a.{~a.i.upper a.) {~ a.i.] > (a. (97+i.26)}~'ABCDEFGHIJKLMNOPQRSTUVWXYZ') {~ a. i. ] > > In other words: > up=: (a. (97+i.26)}~a.{~65+i.26) {~ a. i. ] > (up -: upper) a. > 1 > > Which is essentially your A2Z and a2z -- everything between > those parenthesis will be evaluated only once (when the verb > is defined). > > And, as you have noted, you can define lower basically the same way > (swapping 65 and 97 in this case). > > In other words, most of the complexity of this problem has to > do with specifying the upper case and lower case sets of characters. > > That said, in terms of efficiency, these approaches are essentially > identical: > ts=:6!:2,7!:2 > text=:a.{~32+?1e7#95 > ts 'up text' > 0.019557 1.6778e7 > ts 'upper text' > 0.01945 1.67781e7 > ts 'up text' > 0.019705 1.6778e7 > ts 'upper text' > 0.0207132 1.67781e7 > ts 'up text' > 0.0194938 1.6778e7 > ts 'upper text' > 0.0217025 1.67781e7 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
