Symbol Column Update

Question: Define a function updSymCol that takes in a table as a value or reference, column name, function to operate on the column that returns an updated column list, and enumeration domain (symbol, filepath) that the column is enumerated against. If a table reference is passed in, the update should be persisted and the reference should be returned, otherwise the updated value is returned.

Example

                                
                                q)show t:([]s:`AAPL`IBM`MSFT;p:100 200 300)
s    p
--------
AAPL 100
IBM  200
MSFT 300
q)`sym set `$()
`sym
q)updSymCol[t;`s;lower;`sym]
s    p
--------
aapl 100
ibm  200
msft 300
q)sym
`aapl`ibm`msft
q)updSymCol[`t;`s;upper;`sym]
`t
q)t
s    p
--------
AAPL 100
IBM  200
MSFT 300
q)sym
`aapl`ibm`msft`AAPL`IBM`MSFT
q)`:t/ set .Q.en[`:.] t
q)updSymCol[`:t/;`s;{`$1 rotate' string x};`:sym]
`:t/
q)updSymCol[`:t/;`s;{`$1 rotate' string x};`:sym]
`:t/
q)get `:t
s    p
--------
PLAA 100
MIB  200
FTMS 300
q)get `:sym
`AAPL`IBM`MSFT`APLA`BMI`SFTM`PLAA`MIB`FTMS
                                
                            

Solution

Tags:
tables
Searchable Tags
algorithms api architecture csv data structures dictionaries disk feedhandler finance functions ingestion ipc iterators machine learning math multithreading optimizations realtime sql statistics streaming strings tables temporal websockets

Email sent!

Email not sent