A sad story:
]'A B'=:3|L:0(([:<i.)"1)3 5,:5 4
----------T-------┐
│0 1 2 0 1│0 1 2 0│
│2 0 1 2 0│1 2 0 1│
│1 2 0 1 2│2 0 1 2│
│ │0 1 2 0│
│ │1 2 0 1│
L---------+--------
f=: 13 :'(([:<i.)"1)y'
f
([: < i.)"1
f C=:3 5,:5 4
---------------T-----------┐
│ 0 1 2 3 4│ 0 1 2 3│
│ 5 6 7 8 9│ 4 5 6 7│
│10 11 12 13 14│ 8 9 10 11│
│ │12 13 14 15│
│ │16 17 18 19│
L--------------+------------
g=: 13 :'3|L:0 y'
g
3 |L:0 ]
g f C
----------T-------┐
│0 1 2 0 1│0 1 2 0│
│2 0 1 2 0│1 2 0 1│
│1 2 0 1 2│2 0 1 2│
│ │0 1 2 0│
│ │1 2 0 1│
L---------+--------
5!:4 <'f'
-- [:
----+- <
-- " -+ L- i.
L- 1
5!:4 <'g'
-- 3
│ -- |
--+- L: -+- 0
L- ]
'A B'=:g f C
A
0 1 2 0 1
2 0 1 2 0
1 2 0 1 2
B
0 1 2 0
1 2 0 1
2 0 1 2
0 1 2 0
1 2 0 1
Because L: is a conjunction, I thought I had written my first function
that would be a conjunction. However, it is only a verb.
4!:0 <'f'
3
4!:0 <'g'
3
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of R.E. Boss
Sent: Tuesday, October 16, 2012 3:16 AM
To: [email protected]
Subject: Re: [Jprogramming] stitching matrices
I do like the LHS (=/S:0 { ({:"1 A);({."1 B))
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: [email protected]
> [mailto:[email protected]] Namens EelVex
> Verzonden: dinsdag 16 oktober 2012 7:14
> Aan: [email protected]
> Onderwerp: Re: [Jprogramming] stitching matrices
>
> If elegant == short-tacit then Aai's way seems to be the best path to
take.
>
> Otherwise, `catalogue` presents some nice options, like:
>
> (=/S:0 { ({:"1 A);({."1 B)) # (;S:1 { <"1&.>A;}."1 B)
>
>
>
>
> On Mon, Oct 15, 2012 at 8:21 PM, Raul Miller <[email protected]>
wrote:
>
> > Ok, thank you! I am going to blame my confusion about {: vs. {. on
> > my browser font, where both : and . get only a single pixel per dot
> > on my laptop's screen. I can see the difference if I focus on it,
> > but I should have copied those phrases rather than retyping them.
> >
> > That said... note that the asymmetric treatment of A and B ({: vs. {.
> > and the dropping of one column of B and the reordering of the
> > representation of B in the result) all require code to express.
> >
> > Also, the most concise expression would be O(A */@,&$ B) and and
> > it's tempting to try to make this more efficient, by keying on the
> > join column. But that leaves me with something like this:I
> >
> > join1=:4 :0
> > jA=. {:"1 A=.x
> > jB=. {."1 B=.y
> > u=. jA ([ -. -.)&~. jB
> > uA=. (jA e. u) # A
> > tuB=. (jB e. u) # B
> > uB=. (/: u&i.@:({."1)) <mailto:u&i.@:({.> tuB
> > juA=. {:"1 uA
> > juB=. {."1 uB
> > bA=. juA </. uA
> > bB=. juB </. uB
> > ; bA ,/@:(,"1/)each bB
> > )
> >
> > Something like Aai's proposal (;A ((,}.)"1 <@#~ (=&{: |.)"1)"1 _ B)
> > is going to be much more elegant, in my opinion...
> >
> > --
> > Raul
> >
> > On Mon, Oct 15, 2012 at 12:33 PM, R.E. Boss <[email protected]> wrote:
> > > NB. ({:"1 A) equals {."1 B
> > > so not the leading column of A
> > >
> > > Perhaps I should have added that ({:"1 A) =&~. {."1 B or all
> > > not matching rows are deleted.
> > >
> > >
> > > R.E. Boss
> > >
> > >
> > >> -----Oorspronkelijk bericht-----
> > >> Van: [email protected] [mailto:
> > [email protected]] Namens Raul Miller
> > >> Verzonden: maandag 15 oktober 2012 18:24
> > >> Aan: [email protected]
> > >> Onderwerp: Re: [Jprogramming] stitching matrices
> > >>
> > >> Given your description, I would have expected a result like this:
> > >>
> > >> 0 1 2 0 1 1 2 0
> > >> 0 1 2 0 1 1 2 0
> > >> 2 0 1 2 0 0 1 2
> > >> 1 2 0 1 2 2 0 1
> > >> 1 2 0 1 2 2 0 1
> > >>
> > >> I do not understand the result you proposed.
> > >>
> > >> Also, you have not specified what happens for rows where the
> > >> leading column of A has a value which does not appear in the
> > >> leading column of B. I can imagine several treatments for this case:
> > >>
> > >> 1) error
> > >> 2) join to a row of fills
> > >> 3) eliminate the row from the result
> > >>
> > >> Likewise for the reverse case, where the leading column of B has
> > >> a value which does not appear in the leading column of A. (And,
> > >> the asymmetric treatment of A and B, where one of the columns of
> > >> B does not contribute to the result, makes me wonder if the
> > >> treatment for
> > >> {."1 A not in {."1 B might be different from from the treatment
> > >> of
> > >> {."1 B not in {."1 A.)
> > >>
> > >> So... I am confused. Any clarification or explanation you can
> > >> provide could help.
> > >>
> > >> Thanks,
> > >>
> > >> --
> > >> Raul
> > >>
> > >> On Mon, Oct 15, 2012 at 10:59 AM, R.E. Boss <[email protected]>
wrote:
> > >> > Given
> > >> >
> > >> > ['A B' =. 3|L:0<@i."(1)3 5,: 5 4
> > >> > +---------+-------+
> > >> > |0 1 2 0 1|0 1 2 0|
> > >> > |2 0 1 2 0|1 2 0 1|
> > >> > |1 2 0 1 2|2 0 1 2|
> > >> > | |0 1 2 0|
> > >> > | |1 2 0 1|
> > >> > +---------+-------+
> > >> >
> > >> > I want to stitch every row from A with all rows from B where
> > >> > ({:"1 A)
> > equals {."1 B and one of these columns is deleted.
> > >> > This will give me
> > >> >
> > >> > A foo B
> > >> > 0 1 2 0 1 2 0 1
> > >> > 0 1 2 0 1 2 0 1
> > >> > 2 0 1 2 0 1 2 0
> > >> > 2 0 1 2 0 1 2 0
> > >> > 1 2 0 1 2 0 1 2
> > >> >
> > >> > Any elegant solutions?
> > >> >
> > >> >
> > >> > R.E. Boss
> > >> >
> > >> > ---------------------------------------------------------------
> > >> > ------- 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm