Issue with flip in Table Joins

Hi,

 

I am learning about table joins for the first time and have been working through the Joins, Practical Guidance - Joins and Joins Exercises notebooks in the Fundamentals series.

 

I have not been able to figure out some things even after spending much time thinking about them.

 

In the Joins notebook:

t is:

name iq ------------ Harry 98 Ron 42 Hermione 126

meta t is:

c | t f a ----| ----- name| s iq | j

It is stated that t,flip (nameiq!(enlist `Bumble;59)) is:

name iq ------------ Harry 98 Ron 42 Hermione 126 Bumble 59

meta t,flip (nameiq!(enlist `Bumble;59)) is:

c | t f a ----| ----- name| s iq | j

I am unable to figure out why there is no need for enlist 59 in flip (nameiq!(enlist Bumble;59)) i.e. flip (name``iq!(enlist Bumble;enlist 59)). From what I understand, in order to flip a dictionary into a table, the values must be lists of equal length (which I believe is the reason why t,flip (nameiq!(Bumble;59)) results in evaluation error: rank).

enlist `Bumble is a list but 59 is not.

(show dictOne:(nameiq!(enlist `Bumble;59)) is:

name| ,`Bumble iq | 59

type each dictOne is:

name| 11 iq | -7

)

 

I noticed that t,flip (nameiq!( Bumble;enlist 59)) also works as shown below. However, I am unable to figure out why there is no need for enlist Bumble.

t,flip (nameiq!( `Bumble;enlist 59)) is:

name iq ------------ Harry 98 Ron 42 Hermione 126 Bumble 59

meta t,flip (nameiq!( `Bumble;enlist 59)) is:

c | t f a ----| ----- name| s iq | j

This time, enlist 59 is a list but `Bumble is not.

(show dictTwo:(nameiq!(`Bumble;enlist 59)) is:

name| `Bumble iq | ,59

type each dictTwo is: 

name| -11 iq | 7

)

 

From what I understand, there is a need for both enlist Bumble and enlist 59 in the dictionary i.e. flip (name``iq!(enlist `Bumble;enlist 59)). 

t,flip (name``iq!(enlist Bumble;enlist 59)) is:

name iq ------------ Harry 98 Ron 42 Hermione 126 Bumble 59

meta t,flip (name``iq!(enlist Bumble;enlist 59)) is:

c | t f a ----| ----- name| s iq | j

(show dictThree:(name``iq!(enlist Bumble;enlist 59)) is:

name| Bumble iq | 59

type each dictThree is:

name| 11 iq | 7

 )

 

I would greatly appreciate any assistance with this issue.

 

Thank you very much.

This is hinted at in the docs of flip: the values are lists of the same count (or atoms). The “(or atoms)” part is relevant here. If any of the values are atoms, they are extended to the same length as the lists. Therefore it is enough to have only one value be a list and the rest can be atoms. But if there are multiple lists, they must have the same length.

Hi,

 

Thanks for the clarification! I understand it now.