Ric wrote:
>  10&#.^:_1 (or 10&#.inv ) has always seemed to me to be the "right" 
>  way of converting a number to its digits but it is slower and fatter than 
>  the other methods:

Pepe wrote:
>  Perhaps, for the reason that you mentioned, there is case for 
>  special code for ( 10&#.^:_1 ) .

Agreed.  This has bothered me before, but then I'm more of purist and less 
pragmatist when it comes to J.  I imagine many people are
satisfied with the special code supporting   "."0@":  [1].   

>  ( ,.&.": ) is indeed a neat phrase

Also agreed!   However, I am concerned with  (&.":), because it applies  
(":^:_1),  which is  (". ) which obviously can and will
execute arbitrary code.  And this implication may not be obvious to the 
programmer when he types  (&.":).  Now, there's no problem
if he controls (y) but applying these phrases to user strings makes the 
application vulnerable to "J injection" attacks.

This isn't a problem in the current case (because the input is numeric, and 
even if it were a rank-1 string,  (".) would never be
applied to more than one character anyway).    But I do have an open relevant 
enhancement request open on it [2], where I recommend
x&".  be made invertible.

-Dan

[1]  http://www.jsoftware.com/help/release/digits10.htm 
[2]  
http://www.jsoftware.com/jwiki/System/Interpreter/Requests#makedyad.22.invertible
 


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

Reply via email to