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)) 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 <r.e.b...@planet.nl> 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: programming-boun...@forums.jsoftware.com 
>> [mailto:programming-boun...@forums.jsoftware.com] Namens Raul Miller
>> Verzonden: maandag 15 oktober 2012 18:24
>> Aan: programm...@jsoftware.com
>> 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 <r.e.b...@planet.nl> 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

Reply via email to