Say I have a list of symbols like so…
q) list
`hello_world.q
`hello_world_2.q
I’d like to split this so I end up with this list of strings…
q) new_list
"hello_world"
"hello_world_2"
how is that done?
I can do this using something like…
string1: "`" vs string list[0]
string1: "." vs string1[1]
But not sure how to do the full list
You can use vs
, each
and each right (/:
):
q)string first each` vs/:`hello_world.q`hello_world_2.q
"hello_world"
"hello_world_2"
Use case of vs
is documented here: https://code.kx.com/q/ref/vs/#symbol-by-dot
Alternatively:
q)string(` vs'`hello_world.q`hello_world_2.q)[;0]
"hello_world"
"hello_world_2"
Something like: const new_list = list.map(str => str.replace(/^`/, ”).replace(/\.q$/, ”));
hi thanks but i don’t think that’s q syntax?
Oh sorry haha! I do not know why I thought I am answering a JS question. My bad!
lol no worries – thanks for trying to help!