John Baker wrote, in the JOD encoding thread:
>  I just a quite look at the ascii85 verbs.

ASCII85 provides an example of J's stark beauty:

           ascii85 =:  (33 + 85 #.^:_1: 256 #. _4 ]\ ])&.(a.&i.)
           
The example would be even more compelling if it were invertible.  At present, 
this formulation is not, for two reasons:

     (1)  f^:_1:      NB.  note the trailing colon
          is not invertible, and probably never 
          will be:  
http://www.jsoftware.com/jwiki/System/Interpreter/Requests07#head-a937314ba3404f971e079b5d77269131de4ca9ab

     (2)  x&(#.^:_1)  NB.  as opposed to  (x&#.)^:_1
          is not invertible, though someday it 
          might be:  
http://www.jsoftware.com/jwiki/System/Interpreter/Requests#head-6dfc48377d34ebb2235f3c1874230ab35ead51bf

To work around these limitations, we can express the transformation differently:

           ascii85 =:  (33 + [: (85&#.^:_1) 256 #. _4 ]\ ])&.(a.&i.)

which is not so bad, I suppose.  Only 5 characters/4 words longer.  Though the 
cap and the extra nesting irk me.

Of course, for real-world applications, it is better to use the definitions in  
~addons\convert\misc\ascii85.ijs  .  

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

Reply via email to