Re: Small feature request for future EU versions
- Posted by "Igor Kachan" <kinz at peterlink.ru> Oct 28, 2004
- 643 views
OOppss... Me wrote: Patrick Barnes wrote: [snip] > And there you go. The only way to make it faster, I think, is to use a > non-recursive algorithm and maybe restrict it to 1d arrays only. > > The method's only assumption is that no zero-value characters exist > (the null char?). To check for this, just uncomment the checking > code... might make it run a little slower. > > What do you think of this Igor? Handles any odd combination of > alphabets you want to throw at it, I think. > > -- > MrTrick Using all yours people suggestions and questions I have combined the case_xx() function, which is twice as faster than standard case_la(), takes any alphabet and is selective on default. Works with my 5 crazy Russians and pure Mumbo Jumbo as well. Results - 0.3 sec - 3.5M file - 1.8GHz box. Try please:
sequence table table = repeat(0,256) global constant alphabet_LA = "AaBbCcDdEeFfGgIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz", alphabet_MJ = ".....place here The Great Mumbo Jumbo Alphabet...." global function case_xx(integer c, object x, sequence alphabet) integer A, a table *= 0 -- to clear table for next use with another alphabet for i=1 to length(alphabet) - 1 by 2 do A = alphabet[i] a = alphabet[i+1] if c then table[A] = A table[a] = A else table[A] = a table[a] = a end if end for if atom(x) then if x then return table[x] else return x end if else for i=1 to length(x) do a = x[i] if a then -- to convert binary if table[a] then -- to not affect others x[i] = table[a] end if -- end if end for end if return x end function puts(1, case_xx(1, alphabet_LA, alphabet_LA) & '\n') puts(1, case_xx(0, alphabet_LA, alphabet_LA) & '\n') puts(1, alphabet_LA & '\n') puts(1, case_xx(0, 'A', alphabet_LA)& '\n') ---- puts(1, case_xx(1, alphabet_MJ, alphabet_MJ) & '\n') puts(1, case_xx(0, alphabet_MJ, alphabet_MJ) & '\n') puts(1, alphabet_MJ & '\n') ---- puts(1, case_xx(0, 'M', alphabet_MJ) & '\n') puts(1, case_xx(0, 'u', alphabet_MJ) & '\n') ---- puts(1, case_xx(0, case_xx(1, alphabet_LA, alphabet_LA), alphabet_LA) & '\n') ----
Many Thanks To All ! Just add your native alphabet and use (on your own risk OOpsss ... Just next bug fix, see above. Regards, Igor Kachan kinz at peterlink.ru