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?
Asked
Active
Viewed 3,844 times
6 Answers
2
string
will convert them. It's an atomic function
q)string (`A.ABC;`B.DEF;`C.GHI)
"A.ABC"
"B.DEF"
"C.GHI"

Callum Biggs
- 1,539
- 5
- 13
2
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"

Cmccarthy1
- 333
- 1
- 5
1
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.

Rob Sketch
- 361
- 1
- 6
0
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"

abhi
- 1,760
- 1
- 24
- 40
-
2`$` is the k primitive underpinning q's `string` function. It's not advised to use k code, better off sticking with q code, aka the `string` function – terrylynch Apr 01 '20 at 17:06
-
Thanks for the advice @terrylynch, I'll keep that in mind and refrain. – abhi Apr 01 '20 at 17:09
0
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

senthil
- 7
- 1
- 3