cmap is a variation of tr, as in

http://www.jsoftware.com/pipermail/chat/2007-December/000804.html


   'A2Z a2z'=. a.,"1~a.{~(a.i.'Aa')+/i.26
   atr=: 2 : '(m,a.) {~ (n,a.) i. ]'

   a2z atr A2Z 'TeSt 123'
test 123
   A2Z atr a2z 'TeSt 123'
TEST 123

   A2Z atr a2z ^:_1 'TeSt 123'
test 123

--- Jack Andrews <[EMAIL PROTECTED]> wrote:

> hi,
> 
> still learning j... been looking at rosetta code which is handy.  the
> example of changing case here:
>   http://rosettacode.org/rosettacode/w/index.php?title=Change_string_case#J
> 
> and reproduced here:
>   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?
> 
> i don't know if this is any 'better':
> 
>    A2Z=.(a.i.'A')+i.26
>    a2z=.(a.i.'a')+i.26
>    lower=.((a2z{a.) A2Z }a.) {~ a.i.]
>    upper=.((A2Z{a.) a2z }a.) {~ a.i.]
>    upper '123abcDEF'
> 123ABCDEF
>    lower '123abcDEF'
> 123abcdef
> 
> how could i define a word 'cmap' so that
>   lower2=.cmap A2Z a2z
>   upper2=.cmap a2z A2Z
> ?
> 
> ta,  jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to