To test whether a noun is a string, there’s the translation into J of one of 
the first APL idioms I ever learned:

          stringQ =: ‘' -: 0 $ [

Unfortunately, that does not work in J, because a J empty array does not seem 
to have what in APL was called a “type”; in particular, in J (and similarly in 
some versions of APL):

        ‘'  -: i. 0
   1
    
Hence the need in J for the workaround that Raul shows, namely, doing a 1{. 
instead of a 0$.

> On1 Dec 2017 21:34:33 -0500,Raul Miller <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> 
> 1. What do you mean by "an object is string"?
> 
> This might do it:
>   isString=: ' '= 1{.0{.,
> 
> But note that this approach ignores the number of dimensions of the
> value (and don't get me started on "objects").

——
Murray Eisenberg                                [email protected]
Mathematics & Statistics Dept.       
Lederle Graduate Research Tower      phone 240 246-7240 (H)
University of Massachusetts                
710 North Pleasant Street                 
Amherst, MA 01003-9305




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

Reply via email to