I think I'm agreeing with you, but somehow the reasoning leads
us to different answers.
Yes, it should be immaterial what the internal type of
an empty numeric array is. But with the change you have made,
there will be a difference between
{. ; '';0$0 NB. result is ' '
and
{. ; '';0$2 NB. result is 0
One question is, Are these reasonable combinations? I reckon
they are, considering how carelessly some programmers use ''
for an empty list. But no matter what, the type of an empty
numeric should not affect the result of a computation.
So I think you should take the trouble to
switch types 1 and 2 in the priority order.
I really don't care much whether the result of
{. ; '';0$some_numeric_type
is literal or numeric; but I do care that
0) boolean and integer give the same result
1) ;@,&< gives the same result as ,
2) whatever happens is documented
As for (0$3j4);0$s: <'abc' , I don't
care what the result is as long as it's documented.
Type 32 (boxed) is stuck in the middle of the numeric types
too and perhaps should be moved to higher priority than rational.
Henry Rich
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Roger Hui
> Sent: Monday, October 15, 2007 3:04 PM
> To: Programming forum
> Subject: Re: [Jprogramming] inverted table ifa
>
> If "numbers are numbers" then it should be immaterial
> what the internal type of an empty numeric array is.
>
> "Tender mercies" only come into play for unreasonable
> combinations of types. e.g. What should be the
> result type of (0$3j4);0$s: <'abc' ?
>
>
>
> ----- Original Message -----
> From: Henry Rich <[EMAIL PROTECTED]>
> Date: Monday, October 15, 2007 10:49
> Subject: RE: [Jprogramming] inverted table ifa
> To: 'Programming forum' <[email protected]>
>
> > That's certainly an improvement, though there are still
> > 2 problems:
> >
> > 0) That tender-mercies problem, which violates the J principle that
> > numbers are numbers, whether they be boolean, integer, etc.
> > May I suggest that instead of
> >
> > >./ types
> >
> > you code
> >
> > 3&(22 b.) >./ 3&(22 b.) types
> >
> > [BTW, m&(22 b.) could be self-inverse.]
> >
> > 1) The incompatibility with , . x ;@,&<
> > y really should,
> > methinks, always be the same as x , y . The
> > change makes
> > it closer but still not the same. I would be content if
> > both of them worked as described in (0) above.
> >
> > [BTW, Mark's hand-coded raze =: >@(,&.>/)@, is not an
> > accurate model of ; . ; is tricky to model because of the
> > treatment of scalars and dissimilar ranks, and I view ;
> > as the primitive operation from which , is derived. I
> > take it from comments made in the past that my view is not
> > universal, but I find it easier to describe the verbs that
> > way, and it's one reason why I would really like , to
> > be identical to ;@,&< .
> >
> > Henry Rich
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Roger Hui
> > > Sent: Monday, October 15, 2007 10:29 AM
> > > To: Programming forum
> > > Subject: Re: [Jprogramming] inverted table ifa
> > >
> > > The problem with ifa comes down to the result of
> > > > '';''
> > > which is currently an empty Boolean array.
> > > I have changed the implementation of the monad >
> > > for the next J602 beta such that if all the opened
> > > atoms of the argument are empty, then the type of the
> > > result is the maxtype of the types of the opened atoms.
> > > Consequently, if the combinations of these types are
> > > reasonable (such as in '';'' or (0$0);0$0.5), then the
> > > result type is reasonable; if not, then you are at the
> > > tender mercies of maxtype. (Which, among other
> > > things, depends on the idiosyncratic numbering
> > > of the internal types.)
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: bill lam <[EMAIL PROTECTED]>
> > > Date: Monday, October 15, 2007 6:58
> > > Subject: Re: [Jprogramming] inverted table ifa
> > > To: Programming forum <[email protected]>
> > >
> > > > Roger Hui wrote:
> > > > > So what should be the result of the following and why?
> > > > > > (3 0$0 );(0 4$'')
> > > > > > (4 0$'');(3 0$0 )
> > > >
> > > > There ain't such thing in the context of inverted table. I
> > > > wasn't asking
> > > > theoretical question. A practical scenario is importing data
> > > > from excel having 2
> > > > columns for code and descriptions such as,
> > > > code descr
> > > > A aaa
> > > > B bbbbbb
> > > > C cccccccccc
> > > > They are read into rank-2 box text array and then converted
> > into
> > > > inverted table
> > > > for processing. The description cell may be very long and it
> > may
> > > > need to limit
> > > > to a certain length, so that {. is needed, say
> > > > descr=. 10{. 1{:: ivt
> > > >
> > > > Someone may not fill anything in an entire text column
> > inside
> > > > excel. I think
> > > > that Henry's suggestion works for me.
> > > > < 6{.(!.' ')("1) 1{:: ifa 3 2$ 'ab';''
> > > > +------+
> > > > | |
> > > > | |
> > > > | |
> > > > +------+
> > > > Thanks to Henry for workaround suggestion and Roger for
> response.
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm