Anssi Seppälä wrote:
>  My "hate" today  is:
>    ".'2.5E-2'
>  |ill-formed number
>  |       ".'2.5E-2'
>    0 ".'2.5E-2'
>  0.025

I never use the monad  ".  when I just want to convert strings to numbers.  The 
major reason is exactly your "hate":  the dyad
converts  -  to  _  but the monad doesn't.   Of course, this is the correct 
behavior for the monad, which is a J interpreter (and I
would be very unhappy with a J interpreter that substituted _s for my -s), but 
I'm glad the dyad has specifically extended this
convenience.  

Actually, the very fact that monad   ".  is a J interpreter is a disincentive 
to using it to convert (presumably user-entered)
strings into numbers.  What if the sneaky user entered   2!:55]0   or worse,   
1!:55 'C:\*.*'    ?  Yikes.

-Dan

PS:  It may surprise some that the constant  2.5E_2  (capital E) is actually 
permissible, in contradiction to §Constants.    So if
you *really* wanted to use the monad instead of the dyad, you could write, e.g. 
 ".@:('-'&=`(,:&'_')}) '2.5E-2'   .


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

Reply via email to