Search code examples
kdb

How do I stack matrices in KDB?


I'm trying to insert a new row at the beginning of a matrix, but the result is inserting my row vector rotated:

a: (.7 .3; .1 .2)
b: (.5 .5)

b, a

0.5
0.5
0.7 0.3
0.1 0.2

Intended result:

0.5 0.5
0.7 0.3
0.1 0.2

What am I doing wrong?


Solution

  • (enlist b), a gives the result you want. It helps to think of a as being made from nested lists, hence any new rows should be of this form as well.