Roger Hui <[EMAIL PROTECTED]> wrote:

> > reliable, predictable behavior of empties
>
> So what should be the result of the following and why?
>    > (3 0$0 );(0 4$'')
>    > (4 0$'');(3 0$0 )

Unfortunately, the dictionary does not get specific about
such things. However, I always thought the conventional
wisdom was:

0) Whenever an empty is used in a context where its type
   is inappropriate, it is coerced into an appropriate type
   (like ''$x)
1) Hence, Whenever an empty is combined with a non-empty,
   the result assumes the type of the non-empty
   (like '',i.5 or 'abc',i.0)
2) Whenever two empties are used together, it is unpredictable
   which of the two types the result will follow; it will
   follow one or the other. (like '',i.0)
3) Hence, if two empties of the same type are used together,
   the result should be of the same type. (like '','')

So, in your two examples above, the implementation is free
to choose whether the result should be numeric or character.
However, in
    > (4 0$'');(0 3$'' )
the result ought to be characters (rather than zeros,
as is currently the case).

Note that '','' produces characters as expected; however,
;'';'' or >'';'' (boiled-down versions of the original problem)
produce booleans, even though one might expect the same
as '',''

On the other hand, I can see how the implied rank operator
(in the case of >'','') or the implied append (in ;'','')
might just start with an empty boolean and add empties to
it (preserving the boolean type). However,
a hand-coded raze produces the 'expected' results:
   raze =: >@(,&.>/)@,
   3!:0 raze '';''
2
   3!:0 ;'';''
1

Empty arrays sometimes make my brain hurt.

-- Mark D. Niemiec <[EMAIL PROTECTED]>

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

Reply via email to