1

I'm trying to join multiple tables in q

        a                  b                  c
    key | valuea       key | valueb       key | valuec
     1  |   xa          1  |   xb          2  |   xc
     2  |   ya          2  |   yb          4  |   wc
     3  |   za  

The expected result is

    key | valuea | valueb | valuec
     1  |   xa   |    xb  |   
     2  |   ya   |    yb  |   xc
     3  |   za   |        |   
     4  |        |        |   wc

The can be acheieved simply with

    (a uj b) uj c

BUT does anyone know how i can do it in functional form? I don't know how many tables i actually have

I need basically a function that will go over the list and smash any number of keyed tables together...

f:{[x] x uj priorx};
f[] each (a;b;c;d;e...)

Can anyone help? or suggest anything?

Thanks!

thefourtheye
  • 233,700
  • 52
  • 457
  • 497
Rob
  • 793
  • 1
  • 7
  • 8

2 Answers2

1

figured it out... ;)

f:{[r;t]r uj t};
f/[();(a;b;c)]
Rob
  • 793
  • 1
  • 7
  • 8
1

Another solution particular to your problem which is also little faster than your solution:

a (,')/(b;c)

Rahul
  • 3,914
  • 1
  • 14
  • 25