Reputation: 1027
I am trying to create a table of symbols in kdb, where the values of the table have spaces within. I have got
tab:([colOne:`$"value 1"`$"value 2"]colTwo:`$"value 3"`$"value 4")
currently, but this just returns
ERROR: `type (wrong type)
i have followed http://www.kdbfaq.com/kdb-faq/tag/sym-with-a-space
Upvotes: 4
Views: 2210
Reputation: 1087
you are right about sym with a space part but while creating a table columns take lists as inputs.
tab:([colOne:`a`b]colTwo:`c`d)
would be ok as `a`b
is a list but when using syms with spaces you need to enclose them in ()
to make a list.
below will also work though sergey's answer is a better way of doing it.
tab:([colOne:(`$"value 1";`$"value 2")]colTwo:(`$"value 3";`$"value 4"))
Upvotes: 2
Reputation: 231
Should be:
tab:([colOne:`$("value 1";"value 2")]colTwo:`$("value 3";"value 4"))
Remember that evaluation in q is left-to-right:
colTwo:`$"value 3"`$"value 4"
`$"value 4" will be evaluated to symbol
Then it will try to apply this symbol to what's on the left:
"value 3" `$"value 4"
which will give you 'type
Upvotes: 2