Correct.

The following example may be more convincing:

   x=: ];._1 ' Devon Roger Ken Morten'
   y=: ];._1 ' Roger Sextus'
   x
Devon
Roger
Ken
Morten
   y
Roger
Sextus

   y e. x
1 0

One way to define membership is y e. x iff (#x)>x i. y.  Defining the "set
functions" this way makes even more sense in Dyalog APL, which has union,
intersection, set difference, ...

member    ← {(≢⍵)>⍵⍳⍺}
unique    ← {⍵ ⌿⍨ (⍳≢⍵)=⍵⍳⍵}
without   ← {⍺ ⌿⍨ ~(⍺⍳⍺)∊,⍺⍳⍵}
intersect ← {⍺ ⌿⍨  (⍺⍳⍺)∊,⍺⍳⍵}
union     ← {⍺⍪(↑,⊂⍤(¯1+⍴⍴⍺)⊢⍵) without ⍺}

Alas, the one for member can not be used because ⍺∊⍵ ←→ ⍺∊,⍵.  At least, it
can not be used if we want to be compatible with old code.  (≢ is tally, ⍨
is commute.)




On Thu, Nov 20, 2014 at 10:31 AM, Devon McCormick <devon...@gmail.com>
wrote:

> I see, so
>
>    0 1 e. i.2 2
> 1
>
>
> On Thu, Nov 20, 2014 at 1:27 PM, Roger Hui <rogerhui.can...@gmail.com>
> wrote:
>
> > Both expressions give the correct answer.
> >
> > The right argument of membership determines the target of the items to be
> > sought, just like the left argument of index-of determines the targets.
> In
> > my opinion, the APL\360 team made a mistake by making x∊y the same as
> > x∊,y.  We are struggling with the consequences of this in Dyalog APL,
> where
> > ⍳ was recently extended to accept higher-ranked left arguments.  The
> > mistake from long-ago prevents the similar extension to ∊.
> >
> >
> >
> >
> > On Thu, Nov 20, 2014 at 10:19 AM, Devon McCormick <devon...@gmail.com>
> > wrote:
> >
> > > Hi -
> > >
> > > I was just burned by this apparent anomaly:
> > >    1 e. 0~: i. 2 2
> > > 0
> > >
> > > but
> > >    1 e. , 0~: i. 2 2
> > > 1
> > >
> > > Has anyone else noticed this?  Am I right in thinking this is incorrect
> > > behavior in the first case?
> > >
> > > Regards,
> > >
> > > Devon
> > > --
> > > Devon McCormick, CFA
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
>
> --
> Devon McCormick, CFA
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to