bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inner join vs. outer join


From: Jay Foad
Subject: Re: Inner join vs. outer join
Date: Tue, 14 Apr 2020 10:51:35 +0100

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

[Prev in Thread] Current Thread [Next in Thread]