bug-apl
[Top][All Lists]

## Re: Inner join vs. outer join

 From: Elias Mårtenson Subject: Re: Inner join vs. outer join Date: Tue, 14 Apr 2020 18:05:18 +0800

Thank you. That makes sense.

Jürgen, I was referring to the ISO spec. I noticed that J has somehow generalised the join operation so that the / has to be explicit. That surely makes it more flexible, but I'm not sure what you can do with it, to I turned to the spec.

Regards,
Elias

On Tue, 14 Apr 2020 at 17:51, Jay Foad <address@hidden> wrote:
s/join/product/ ?

In APL's inner product (X a.b Y), each item of the result corresponds to a row of X combined in some way with a column of Y. So the shape of the result is (¯1↓⍴X),(1↓⍴Y).

In APL's outer product (X ∘.b Y), each item of the result corresponds to an item of X combined in some way with an item of Y. So the shape of the result is (⍴X),(⍴Y).

J probably does this in a more generic way, and you can certainly implement inner and outer products and variations thereof by using the Rank operator. For example:
X (b⍤99⍤0 99) Y  ⍝ implements X ∘.b Y (where 99 is an approximation to infinity)
X({+⌿⍺(×⍤¯1)⍵}⍤1 99)Y ⍝ implements X +.× Y

Jay.

On Tue, 14 Apr 2020 at 05:07, Elias Mårtenson <address@hidden> wrote:
I was reading the spec on outer join to see if I could finally fully understand how it works.

For reference, the spec refers to the syntax as follows:

X a.b Y

The function a is referenced twice in the description for this function, both times in the form a/ (i.e. with the reduce operator applied).

I then noted that the J version of this function does not apply the reduce operator. I.e. in J, you have to do:

X a/.b Y

Now, am I correct in my assumption that with this change, there would be no need for the ∘ (null function)? I.e. if APL behaved like J, would the following achieve an outer join?

X ⊣.× Y

I'm still not sure I fully understand the join operator to the point where I can answer this question.

Regards,
Elias

reply via email to