Reputation: 1756
For example, if I have a list of symbols i.e (`A.ABC;`B.DEF;`C.GHI)
or (`A;`B;`C)
, how could I convert each item in the list to a string?
Upvotes: 1
Views: 6819
Reputation: 19
use String() function.
q)d
employeeID firstName lastName
-----------------------------------------------------
1001 Employee 1 First Name Employee 1 Last Name
1002 Employee 2 First Name Employee 2 Last Name
q)update firstName:string(firstName) from `d
`d
q)d
employeeID firstName lastName
-------------------------------------------------------
1001 "Employee 1 First Name" Employee 1 Last Name
1002 "Employee 2 First Name" Employee 2 Last Name
Upvotes: 1
Reputation: 1756
Thanks all, useful answers! While I was trying to solve this on my own in parallel, I came across ($)
that appears to work as well.
q)example:(`A;`B;`C)
q)updatedExample:($)example;
q)updatedExample
enlist "A"
enlist "B"
enlist "C"
Upvotes: 0
Reputation: 371
As the others have mentioned, string
is what you're after. In your example if you're interested in separating the prefix and suffix separated by the .
you can do
q)a:(`A.ABC;`B.DEF;`C.GHI)
q)` vs' a
A ABC
B DEF
C GHI
and if you want to convert these to strings you can just use string
again on the above.
Upvotes: 1
Reputation: 388
You can use the keyword string to do this documented here
q)lst:(`A;`B;`C)
// convert to list of strings
q)string lst
,"A"
,"B"
,"C"
Upvotes: 2
Reputation: 1540
string
will convert them. It's an atomic function
q)string (`A.ABC;`B.DEF;`C.GHI)
"A.ABC"
"B.DEF"
"C.GHI"
Upvotes: 2