是否存在与以下等效的函数形式?
trades:([]date:`date$();time:`time$();sym:`symbol$();price:`real$();size:`int$(); cond:`char$())
假设函数名是“ct”...
交易:ct[fieldNames;types]
最佳答案
ct:{[fields;types] flip fields!types$\:()}
例子:
q)ct[`date`time`sym`price`size`cond;`date`time`symbol`float`long`symbol]
date time sym price size cond
-----------------------------
也适用于 char 形式的类型:
q)ct[`date`time`sym`price`size`cond;"dtsfjs"]
date time sym price size cond
-----------------------------
关于KDB/k : Functional form to create a table variable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35252445/