Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

kdb/q How to append a list to a table?

I have a table like this:

nameTable

Name Included
Ann 1
Bob 0
Cat 1

I have a function that gets the "bits" from the Included? column:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

// get the bits
fGetBits:{[nameTable]
  nameTable: select Included from nameTable;
  //BitsTable
  value flip nameTable}

This returns the following, of type 0h:

1 0 1

My question is how can I then take this 0h list and add it back to the Included column of the nameTable table, replacing the current values?

So for example, if I had the following:

0 1 1

I want my table to now look like this:

Name Included
Ann 0
Bob 1
Cat 1

Thanks for the help.

>Solution :

Also worth mentioning a simple update statement https://code.kx.com/q/ref/update/

q)update Included:011b from([] Name:`Ann`Bob`Cat;Included:101b)
Name Included
-------------
Ann  0
Bob  1
Cat  1
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading