4 $.$.=l2
0  0
0  7
1  1
2  2
2  6
3  3
3  5
3  8
4  4
4  9
4 11
5 10

R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: Programming <[email protected]>
> Namens Ric Sherlock
> Verzonden: maandag 14 januari 2019 06:15
> Aan: Programming JForum <[email protected]>
> Onderwerp: Re: [Jprogramming] Finding indices
> 
> Basically you are seeing the result of monadic =
> 
> l2
> 
> 5 2 3 4 6 4 3 5 4 6 7 6
> 
> = l2
> 
> 1 0 0 0 0 0 0 1 0 0 0 0
> 
> 0 1 0 0 0 0 0 0 0 0 0 0
> 
> 0 0 1 0 0 0 1 0 0 0 0 0
> 
> 0 0 0 1 0 1 0 0 1 0 0 0
> 
> 0 0 0 0 1 0 0 0 0 1 0 1
> 
> 0 0 0 0 0 0 0 0 0 0 1 0
> 
> <@I. = l2
> 
> ┌───┬─┬───┬─────┬──────┬──┐
> 
> │0 7│1│2 6│3 5 8│4 9 11│10│
> 
> └───┴─┴───┴─────┴──────┴──┘
> 
> 
> I think you can simplify your Idot to:
>    Idot=: [: <@I. =
> 
> It would be interesting to understand the actual problem you are trying to
> solve with Idot.
> 
> 
> On Mon, Jan 14, 2019 at 5:56 PM 'Skip Cave' via Programming <
> [email protected]> wrote:
> 
> > Ok. You have convinced me to go with the empty box as a null
> > indicator. In that case, we can make  the Idot verb dyadic, and generalize 
> > it:
> >
> >     Idot =.[:I.&.>[:{="1
> >
> > l1 =. 1 2 3 4 6 4 3 4 4 6 7 6
> >
> > 5 Idot l1
> >
> > ┌┐
> >
> > ││
> >
> > └┘
> >
> > l2 =. 5 2 3 4 6 4 3 5 4 6 7 6
> >
> > 5 Idot l2
> >
> > ┌───┐
> >
> > │0 7│
> >
> > └───┘
> >
> > ]m=.|:1 2 3 4,. 2 5 5 5,. 5 4 3 2 ,. 2 3 5 4,. 2 5 4 5
> >
> > 1 2 3 4
> >
> > 2 5 5 5
> >
> > 5 4 3 2
> >
> > 2 3 5 4
> >
> > 2 5 4 5
> >
> > 5 Idot m
> >
> > ┌┬─────┬─┬─┬───┐
> >
> > ││1 2 3│0│2│1 3│
> >
> > └┴─────┴─┴─┴───┘
> >
> > ]n=.|:2 5 5 5,. 1 2 3 4,. 5 4 3 2 ,. 2 3 5 4,. 2 5 4 5
> >
> > 2 5 5 5
> >
> > 1 2 3 4
> >
> > 5 4 3 2
> >
> > 2 3 5 4
> >
> > 2 5 4 5
> >
> > >m;n
> >
> > 2 5 5 5
> >
> > 1 2 3 4
> >
> > 5 4 3 2
> >
> > 2 3 5 4
> >
> > 2 5 4 5
> >
> > 1 2 3 4
> >
> > 2 5 5 5
> >
> > 5 4 3 2
> >
> > 2 3 5 4
> >
> > 2 5 4 5
> >
> >
> > 5 Idot > m;n
> >
> > ┌─────┬─────┬─┬─┬───┐
> >
> > │1 2 3│ │0│2│1 3│
> >
> > ├─────┼─────┼─┼─┼───┤
> >
> > │ │1 2 3│0│2│1 3│
> >
> > └─────┴─────┴─┴─┴───┘
> >
> >
> > NB. It's interesting what the monadic use of Idot does:
> >
> >
> > Idot l1
> >
> > ┌─┬─┬───┬───────┬──────┬──┐
> >
> > │0│1│2 6│3 5 7 8│4 9 11│10│
> >
> > └─┴─┴───┴───────┴──────┴──┘
> >
> > Idot l2
> >
> > ┌───┬─┬───┬─────┬──────┬──┐
> >
> > │0 7│1│2 6│3 5 8│4 9 11│10│
> >
> > └───┴─┴───┴─────┴──────┴──┘
> >
> > Idot m ┌─┬─────┬─┬─┐ │0│1 │2│3│ ├─┼─────┼─┼─┤ │0│1 2 3│ │ │
> > ├─┼─────┼─┼─┤
> > │0│1 │2│3│ ├─┼─────┼─┼─┤ │0│1 │2│3│ ├─┼─────┼─┼─┤ │0│1 3 │2│
> │
> > └─┴─────┴─┴─┘
> >
> > Idot n
> >
> > ┌─┬─────┬─┬─┐
> >
> > │0│1 2 3│ │ │
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 3 │2│ │
> >
> > └─┴─────┴─┴─┘
> >
> > Idot >m;n
> >
> > ┌─┬─────┬─┬─┐
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 2 3│ │ │
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 3 │2│ │
> >
> > └─┴─────┴─┴─┘
> >
> >
> > ┌─┬─────┬─┬─┐
> >
> > │0│1 2 3│ │ │
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 │2│3│
> >
> > ├─┼─────┼─┼─┤
> >
> > │0│1 3 │2│ │
> >
> > └─┴─────┴─┴─┘
> >
> > Can you explain what's going on here?
> >
> >
> > Skip Cave
> > Cave Consulting LLC
> >
> >
> > On Sun, Jan 13, 2019 at 8:02 PM Ric Sherlock <[email protected]> wrote:
> >
> > > Depending on what you are trying to acheive, I think I'd represent
> > > the
> > lack
> > > of a match in a row as an empty rather than a _1:
> > >
> > > <@I."1 ] 5=m
> > >
> > > ┌┬─┬─┬─┐
> > >
> > > ││3│0│2│
> > >
> > > └┴─┴─┴─┘
> > >
> > >
> > > Of course if you need the _1 then you can transform the above
> > >
> > > ;@([: (a:=])`((<_1),:~ ])} <@I."1) 5 = m
> > >
> > >
> > > On Mon, Jan 14, 2019 at 10:42 AM 'Skip Cave' via Programming <
> > > [email protected]> wrote:
> > >
> > > > What I would really like is for I. to return a _1 whenever there
> > > > is no
> > 1
> > > in
> > > > the match array, since there cannot be a negative index:
> > > >
> > > > I.5=1 2 3 4 6 4 3 4 4 6 7 6
> > > >
> > > > 4 8 10
> > > >
> > > > Idot 5=1 2 3 4 6 4 3 4 4 6 7 6
> > > >
> > > > _1
> > > >
> > > >
> > > > ]m=.|:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > >
> > > > 1 2 3 4
> > > >
> > > > 2 3 4 5
> > > >
> > > > 5 4 3 2
> > > >
> > > > 2 3 5 4
> > > >
> > > > 5=m
> > > >
> > > > 0 0 0 0
> > > >
> > > > 0 0 0 1
> > > >
> > > > 1 0 0 0
> > > >
> > > > 0 0 1 0
> > > >
> > > > ,Idot .5=m
> > > >
> > > > _1 3 0 2
> > > >
> > > >
> > > > Can a verb Idot be designed, that does this?
> > > >
> > > > Skip Cave
> > > > Cave Consulting LLC
> > > >
> > > >
> > > > On Sun, Jan 13, 2019 at 2:41 PM Henry Rich <[email protected]>
> > wrote:
> > > >
> > > > > Right.  Prefer (I.@:= ,) to I.@,@:= since it uses special code.
> > > > >
> > > > > Henry Rich
> > > > >
> > > > > On 1/13/2019 2:54 PM, 'Mike Day' via Programming wrote:
> > > > > > You often see this sort of thing, returning pairs of indices
> > > > > > of all
> > > > > occurrences:
> > > > > >
> > > > > >     5 ($@] #.inv I.@,@:=) |: 1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2
> > > > > > 3 5
> > 4
> > > > > > 1 3
> > > > > > 2 0
> > > > > > 3 2
> > > > > >
> > > > > > You can obviously get the row indices using {:”1 or some such,
> > > > > > and
> > > you
> > > > > can of course make the bracketed code a named dyadic verb,
> > > > > >
> > > > > > Cheers,
> > > > > >
> > > > > > Mike
> > > > > >
> > > > > >
> > > > > > Sent from my iPad
> > > > > >
> > > > > >> On 13 Jan 2019, at 17:55, 'Skip Cave' via Programming <
> > > > > [email protected]> wrote:
> > > > > >>
> > > > > >> I know I can find the location (index) of a specific integer
> > > > > >> in a
> > > > > vector of
> > > > > >> integers using I.
> > > > > >>
> > > > > >> I.5=1 2 3 4 5 4 3 4 5 6 5 6
> > > > > >>
> > > > > >> 4 8 10
> > > > > >>
> > > > > >>
> > > > > >> So I want to find the row index of a specific integer in an
> > > > > >> array
> > of
> > > > > >> integers:
> > > > > >>
> > > > > >> |:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > > > >>
> > > > > >> 1 2 3 4
> > > > > >>
> > > > > >> 2 3 4 5
> > > > > >>
> > > > > >> 5 4 3 2
> > > > > >>
> > > > > >> 2 3 5 4
> > > > > >>
> > > > > >> 5=|:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > > > >>
> > > > > >> 0 0 0 0
> > > > > >>
> > > > > >> 0 0 0 1
> > > > > >>
> > > > > >> 1 0 0 0
> > > > > >>
> > > > > >> 0 0 1 0
> > > > > >>
> > > > > >> ,I. 5=|:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > > > >>
> > > > > >> 0 3 0 2
> > > > > >>
> > > > > >>
> > > > > >> The first zero indicates that there is no 5 in the first row.
> > > > > >> The
> > > > second
> > > > > >> zero gives the index of the 5 in the third row. How can I
> > > > > >> tell
> > > whether
> > > > > the
> > > > > >> zero is an index, or a null indicator?
> > > > > >>
> > > > > >> Skip
> > > > > >>
> > > --------------------------------------------------------------------
> > > --
> > > > > >> For information about J forums see
> > > > http://www.jsoftware.com/forums.htm
> > > > > >
> > > --------------------------------------------------------------------
> > > --
> > > > > > For information about J forums see
> > > http://www.jsoftware.com/forums.htm
> > > > >
> > > > >
> > > > > ---
> > > > > This email has been checked for viruses by AVG.
> > > > > https://www.avg.com
> > > > >
> > > > >
> > ----------------------------------------------------------------------
> > > > > For information about J forums see
> > http://www.jsoftware.com/forums.htm
> > > > ------------------------------------------------------------------
> > > > ---- For information about J forums see
> > > > http://www.jsoftware.com/forums.htm
> > > --------------------------------------------------------------------
> > > -- For information about J forums see
> > > http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> 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