To split hairs, an empty array does have a type.  That type determines what is produced if you apply {. for example.  But many verbs, including x -: y, ignore the type of an empty array. Importantly, most verbs treat an empty array of boxes as if it were not boxed.

Henry Rich

On 12/2/2017 10:36 AM, Murray Eisenberg wrote:
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


---
This email has been checked for viruses by AVG.
http://www.avg.com

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

Reply via email to