how to understand the code below

suppose you have a table with several columns named col1 like 3Y5Y and col2 like 3Y4Y so they are vector of symbols and call table t

 

how can i read the below two queries

 

  1. update {y,x} '[iasc each col1;col2] from t

  2. delete from t where 0< sum each =/:(col1,@[;0] each col2) 

Hello @chan_chenyanj,

At first glance, ‘1’ seems erroneous. I suspect a rank error when you run ‘1’ with root cause ‘iasc each col1’.

The ‘iasc’ keyword accepts a list or a dictionary and col here is a simple symbol list and so there would be no need for ‘each’. ‘iasc’ returns the indexes needed to sort the list in ascending order.

Remove ‘each’ and step through to see the output.

Before stepping through ‘2’, is your intention to query original t, or query an updated table that you could assign to ‘1’ (currently would suspect an error returned for both cases)

I can run the code next week and explain the logic further. Fellow contributors may be able to share in the meantime.

Happy Coding.

Hello @chan_chenyanj,

As we discussed previously regarding ‘1’, including ‘each’ here will return a rank error given that ‘iasc’ accepts a list as its argument and 3Y5Y is a simple symbol list. 

To elaborate on ‘2’, I believe you want to query an updated table created after running ‘1’, i.e., assign ‘1’ (without each)

‘2’ logic is erroneous. `@ needs to be replaced with '@. To explain the logic, it is determining whether or not the new columns have a null symbol, and if it does, then delete from the table. 

Happy Coding,

Leah