Home › Forums › kdb+ › Struggling to understand two statements › Re: Struggling to understand two statements
-
1. : represents each left and $ is casting.
https://code.kx.com/q/ref/maps/#each-left-and-each-right
https://code.kx.com/q4m3/7_Transforming_Data/#72-cast
So for the line “nsfi”$:() it is actually casting an empty list with every type on the left (hence each left) so that it creates a list of that specific type. You can use .Q.s1 to view the string representation of the object.
https://code.kx.com/q/ref/dotq/#qs1-string-representation
q)"n"$() `timespan$() q).Q.s1 "nsfi"$:() "(`timespan$();`symbol$();`float$();`int$())"
2. bang (!) is used to create a dictionay with the keys on the left and values on the right with the correct length of list. Then flipping a dict will turn it into a tbl.
https://code.kx.com/q/ref/dict/
https://code.kx.com/q/kb/faq/#flip-a-column-dictionary
3. 2! enkeys the table by the first 2 cols.
https://code.kx.com/q/ref/enkey/
Hope this helps!