How to join multiple tables

安稳与你 提交于 2019-12-06 13:35:12

问题


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!


回答1:


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

a (,')/(b;c)




回答2:


figured it out... ;)

f:{[r;t]r uj t};
f/[();(a;b;c)]


来源:https://stackoverflow.com/questions/24197779/how-to-join-multiple-tables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!