| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: More on lists and sets
Mikito Harakiri wrote:
> Marshall Spight wrote:
> > > > As join/intersection is noncommutative, we have left selection and right
> > > selection.
> >
> > I don't see why it's not commutative.
>
> Example:
>
> 1->2->1 /\ 2->1->2
>
> A(x,y)
> -------
> 1 0
> 2 1
> 1 2
>
> B(x,z)
> -------
> 2 0
> 1 1
> 2 2
>
> Join the relations
>
> A(x,y)&&B(y,z)
> -------------
> 2 1 0
> 1 0 1
> 1 2 1
> 2 1 2
>
> Order
>
> A(x,y)&&B(y,z)
> -------------
> 2 1 + 0*100 = 1
> 1 0 + 1*100 = 100
> 1 2 + 1*100 = 102
> 2 1 + 2*100 = 201
>
> The result: 2->1->1->2
>
>
> 2->1->2 /\ 1->2->1
>
> This have to be ordered differently
>
> A(x,y)&&B(y,z)
> -------------
> 1 0*100 + 1 = 1
> 2 1*100 + 0 = 100
> 2 1*100 + 2 = 102
> 1 2*100 + 1 = 201
>
> The result: 1->2->2->1
That would be a one liner in Haskell:
snd( unzip (sort [(100*x+y, a) | (a,x)<- zip [1,2,1] [0..], (b,y)<- zip [2,1,2] [0..], a==b]))
[1,2,2,1]
>
> I use the word "list join" instead of "my list intersection" from now
> on. List join performs two operations at once: selection and ordering
> -- this is why it's not very intuitive, at first.
Sorry, 'join list', as opposed to 'cons list', is at least 20 year old. You need to come up with another name. Received on Mon Mar 27 2006 - 21:07:34 CST
![]() |
![]() |